0

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.

1
  • Sharing the code will be helpful to understand the question better. however is_singular can be used to validate the current single page with the post type. Commented Dec 14, 2022 at 18:56

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.