WordPress.org

Ready to get started?Download WordPress

Forums

php include not activating inside a post (4 posts)

  1. nagzul
    Member
    Posted 4 years ago #

    Hi, I have some php includes in my post. I'm assuming because of the dom structure of loading the php codes wont trigger inside a post.
    So how can I do this?
    Maybe an on load event or java script, I'm clueless can someone help me?

    Basically I made a mini "template" to post in my posts, and compacted it into 10 php include files.
    That's the jiff, so I await for some recommendations.

  2. jonradio
    Member
    Posted 4 years ago #

    For security reasons, WordPress chose to not allow php code in the text of Posts or Pages you create. The two common ways "around" this are:

    1. Plug-ins written by individuals (not the WordPress development team) specifically to allow php code in Posts or Pages
    2. Create your own Template file by modifying existing ones in your chosen Theme, typically single.php for Posts and page.php for Pages, either replacing the existing files or having custom ones that you have to select each time you create a post or page.

    The plug-in directory is here: http://wordpress.org/extend/plugins/

    The best place to start to read about Template files is here: http://codex.wordpress.org/Stepping_Into_Templates

    Personally, I choose a third approach: I used Custom Fields to store php, and inserted it in posts, pages and elsewhere using double square bracks around the Custom Field name. But that required me to change templates and write a function (in php) to look for double square brackets in the content of each post or page.

  3. Samuel B
    moderator
    Posted 4 years ago #

  4. nagzul
    Member
    Posted 4 years ago #

    Thank you guys.

Topic Closed

This topic has been closed to new replies.

About this Topic