• Hi guys,

    I’m apologise in advance if this is something that requires an easy to find fix, but I wasn’t too sure how to phrase my question to find an answer.

    I’m using the Contact Form 7 plugin. I’m using the following code to pull a post with the contact form shortcode embedded.

    <?php
    			$post_id = 51;
    			$queried_post = get_post($post_id);
    			$title = $queried_post->post_title;
    			$excerpt = $queried_post->post_excerpt;
    			$content = $queried_post->post_content;
    			$thumbnail = $queried_post->post_thumbnail;
    			$feat_image = wp_get_attachment_image_src( get_post_thumbnail_id($queried_post->ID), '' );
    		?>
            <section class="page contact-us">
            	<div class="image" style="background-image:url(<?php echo $feat_image[0]; ?>)"></div>
                <section class="text">
                   <div class="inner">
                       <div class="column">
                            <h1><?php echo $title; ?></h1>
                            <h3><?php echo $excerpt; ?></h3>
                            <?php echo $content; ?>
                        </div>
                    </div>
                </section>
            </section>

    The plugin is working on the post’s actual page, but it’s not working when adding the above code to my index.php file (it only displays the shortcode). I’ve tried other plugins but no shortcodes are working when using this code. The client will need the ability to edit the post via the admin panel, so I cannot add the shortcode via PHP,

    What am I doing wrong?

Viewing 1 replies (of 1 total)
  • From what I can see the only step that you’re missing is to run the filters on the pages content, as that’s what does all of the processing for shortcodes. It’s actually easy to fix up. Just replace this:

    <?php echo $content; ?>

    with this:

    <?php echo apply_filters( 'the_content', $content ); ?>

Viewing 1 replies (of 1 total)
  • The topic ‘Plugin working on Post Page but not when embedded’ is closed to new replies.