Support » Plugin: Contact Form 7 » [Plugin: Contact Form 7] form displays in pages but not posts

Viewing 14 replies - 1 through 14 (of 14 total)
  • I just created a page that uses a template other than the default. In this case the form does not show up. The page that does use the default template does display the form. So, now I’m thinking it’s not a page vs. post issue but the default template vs. a custom one. Any ideas?

    Plugin Author Takayuki Miyoshi

    (@takayukister)

    Does your custom template have <?php the_content(); ?> inside it? The default one should have.

    esmi

    (@esmi)

    Forum Moderator

    Not initially. I had echo $post->post_content. However, if I use <?php the_content(); ?> or <?php $post->post_content; ?> it just displays nothing.

    I’m new to wordpress and all of this, so here’s my template. Anyone see a problem with it that would cause this?

    [Code moderated as per the Forum Rules. Please use the pastebin]

    esmi

    (@esmi)

    Forum Moderator

    Never use $post->post_content. Use the_content() instead.

    Okay, but even with the_content(), I’m not getting anything. I’ve even put in some text before the form to see if I get that and no, I don’t get that either.

    Woops, sorry bout the code & forum rules violation. Here’s the pastebin version – http://pastebin.com/1n8qxWtr

    esmi

    (@esmi)

    Forum Moderator

    You can’t add in your own input fields as part of a CF7 form!

    What input fields have I added? For the page content I have the following…

    test
    [contact-form-7 id="99" title="Contact form 1"]

    What’s wrong with that?

    esmi

    (@esmi)

    Forum Moderator

    Sorry – I misread your contact details (tabled layout *shudder*). That template file does not contain a Loop. No Loop – no page content.

    Even with a loop, I’m still not getting the content.

    <div id="dvContactRight">
          <div class="contacttitle">Send a Message</div>
           <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); endwhile; endif;?>
     </div>

    Full code here – http://pastebin.com/7DmhgZFn

    esmi

    (@esmi)

    Forum Moderator

    No – go and read The_Loop and Creating_Your_Own_Page_Templates again. Carefully, this time.

    So apparently I missed the_content() in the loop. For anyone else having an issue, this code works.

    <div id="dvContactRight">
          <div class="contacttitle">Send a Message</div>
          <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); the_content(); endwhile; endif;?>
     </div>
Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘[Plugin: Contact Form 7] form displays in pages but not posts’ is closed to new replies.