Zasekle
Zasekle

Reputation: 57

How to add php code that only runs for a single page on Wordpress

Let me start off by saying that while I have backend programming experience, I am a novice to Wordpress and PHP.

I am trying to add PHP code to a single page. I thought this would be a common paradigm, but I can't seem to find a direct answer for it. From my research I found two general ways that this may be possible (ignoring adding plugins).

  1. Write a custom plugin.
  2. Use a child theme.

However, I would like for a few things to be true.

  1. HTML is modifiable from the Wordpress GUI.
  2. Be able to access elements of the HTML from the PHP code.
  3. PHP code only runs on the single page.
  4. Inherit the current theme/CSS (this isn't as important).

I think the major problem that I face occurs when a template file is used. When I do this, I seem to need to directly code the HTML in. Is there a standard approach to make all of these conditions true? Or if not, is there any way to do it?

Any help is greatly appreciated.

Upvotes: 0

Views: 1190

Answers (1)

LIGHT
LIGHT

Reputation: 5712

If you want to add PHP code to a single page in WordPress, you can use the Insert PHP plugin. This plugin allows you to insert PHP code directly into your WordPress posts and pages, without the need to create a custom plugin or child theme.

Upvotes: 1

Related Questions