• Resolved Rose

    (@eos-rose)


    I’ve got multiple posts with complex content displaying custom field groups. I’ve created a template php file with the standard display I need, but there doesn’t seem to be an easy way to run a php include withing the content. It is really dire that I figure out how to do this or I’ll be pulling my hair out trying to format each post manually.

    And, no, I can’t just place the include above or below the content area.

    How can I get this to work in the content of my post:

    <?php include( TEMPLATEPATH . '/track1.php' ); ?>

Viewing 5 replies - 1 through 5 (of 5 total)
  • hmm.. maybe do a string replace on content ?
    $content = str_replace(‘*track1*’,

    Thread Starter Rose

    (@eos-rose)

    I’m not really familiar with that. Would that replace the content entirely? That’s not really what I’m trying to do. At this point, I’m considering placing ALL content in custom fields and ignoring the content box entirely. If I can make shortcodes work in custom fields, that might be the easiest all the way around.

    Thread Starter Rose

    (@eos-rose)

    P.S. I found a plugin that will display the text of an include, but won’t run the actual PHP code within the include. Huh.

    Try creating a shortcode in your functions file something like(not exactly):

    function track_replace() {
    include( TEMPLATEPATH . '/track1.php' );
    }
    add_shortcode('track', 'track_replace');

    help: https://www.smashingmagazine.com/2009/02/02/mastering-wordpress-shortcodes/

    Then call it with [track] in our posts.

    Thread Starter Rose

    (@eos-rose)

    That sounds promising. I’ll give it a shot!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Add PHP inclue within the post content’ is closed to new replies.