Support » Plugins » [Plugin: Contact Form 7] Code Showing Instead of Actual Form

  • Resolved myaleigh


    Hi All –

    I’m building a custom website and am using the Contact Form 7 plugin for my forms. I’ve activated the plugin and copied the generated code (ex [contact-form 1 “Contact”]) into individual posts like I’ve always done and when I preview the post’s URL everything works.

    The hiccup is because of this particular design I’m using the following code to call the post into my template:

    $post_id = 3;
    $queried_post = get_post($post_id);
    echo $queried_post->post_content;

    So when I preview website instead of seeing the form I see [contact-form 1 “Contact”].

    Now like I said, when I preview the post meaning going to the individual post’s page I see the form so I know my problem centers around the code I’m using to pull the post into the template and the Contact Form 7 plugin. What I don’t know is I can resolve the issue. Is there another line of code I can use that will call the plugin? I figured with querying the post’s content that would work but I guess not.

    Anyone have any ideas?

    Thanks in advance!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi

    There is some code someplace that applies the filters to ->post_content that the_content() does, but I can’t find it at the moment. I suggest using a wp_query loop which gives you access to all template tags

    $queriedPost = new WP_Query();
     while ($queriedPost->have_posts()) : $queriedPost->the_post();

    Thank you stvwlf! Worked like a charm. I’ll have to keep this in mind for future.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Plugin: Contact Form 7] Code Showing Instead of Actual Form’ is closed to new replies.