WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] [Plugin: Contact Form 7] Code Showing Instead of Actual Form (3 posts)

  1. myaleigh
    Member
    Posted 4 years ago #

    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:

    <?php
    $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!

    http://wordpress.org/extend/plugins/contact-form-7/

  2. stvwlf
    Member
    Posted 4 years ago #

    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();
     $queriedPost->query('p=3');
     while ($queriedPost->have_posts()) : $queriedPost->the_post();
        the_content();
     endwhile;
  3. myaleigh
    Member
    Posted 4 years ago #

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

Topic Closed

This topic has been closed to new replies.

About this Topic