Support » Plugins » Adding PHP code to a page

  • I have some PHP code that interfaces with a database, retrieves information (picture, names, etc), for a number of people. In a standalone web page, the code generates the HTML code to make this happen. What do I need to do to get this code to run and display inside one of the pages on my WordPress installation.

    Regards,

Viewing 7 replies - 1 through 7 (of 7 total)
  • Couldn’t you just put the code in a Page Template?

    Thread Starter josephmo

    (@josephmo)

    Thanks for the tip. I’m going to try it.

    @ MichaelH,

    I have the same question, but can’t use a page template. The reason is that I need to be able to use the visual editor on this page still (someone will be changing the content regularly on this page), but I have a custom query that I would like to run on this page.

    Is it at all possible to run PHP in regular WordPress pages?

    @awarner20, yes it is. You would need to edit the default Page Template — it’s usually named page.php in your theme set.

    Hey there phpprincess, nice to see you here…

    Unfortunately, I don’t think your method will work as this custom query would be different on many pages (at least 30). Unless I had one really long if statement perhaps?

    I did try the exec-php plugin, but in order to use that I would need to disable the Visual Editor, which would negate my purpose in trying retain the editing page feature for the user that will be editing these pages.

    For now, I am just using separate page templates, each with custom queries, and each with static HTML. If this needs to be changed by the user, I’ll just have to make those changes for now.

    p.s. These are category page templates.

    @ ssgupta,

    Thanks, but as noted in my previous post above, exec-php will not work for my needs.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Adding PHP code to a page’ is closed to new replies.