https://twitter.com/felafel/status/906162644125659136
@salcode Met you at WC Lancaster. Looking to embed existing php code (not a snippet) in a WP page. Tried a few plugins. Suggestion?
Displaying PHP output on a WordPress page can vary depending on where you want to display the output.
I'd use a WordPress shortcode (I'm giving a talk on Creating Your First Shortcode at WordCamp Philly 2017).
This is most likely relevant if you're using the Genesis framework. In this case you can hook into the relevant action and put your relevant output in the function you attach to the hook.
Finally, you can modify the specific template being displayed. This is going to depend a lot on your theme.
One important thing to remember is you can create a page template specific to the post_id
, (e.g. page-375.php
),
see https://wphierarchy.com/.
I hope this helps. I'd be interested to hear how you ultimately solve the problem.
I ended up taking the page.php for the theme and making my own template page. I just inserted my code in the content area. I am thinking of adding the custom page code as a php include so that it is more clean and maintainable. Making it a widget was not working for me so tried the template and it did. I got the suggested steps from here:
https://stackoverflow.com/questions/2810124/how-to-add-a-php-page-to-wordpress
P.S,. that wphierarchy site is cool.
Thanks for your reply.