WordPress.org

Ready to get started?Download WordPress

Forums

Contact Form 7
[resolved] form displays in pages but not posts (15 posts)

  1. gswartz
    Member
    Posted 2 years ago #

    I have been able to get the contact form to show up in a page but when I put the same code in a post it just renders the tag instead of the form. Anyone know why? Thanks.

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

  2. gswartz
    Member
    Posted 2 years ago #

    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?

  3. Takayuki Miyoshi
    Member
    Plugin Author

    Posted 2 years ago #

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

  4. esmi
    Forum Moderator
    Posted 2 years ago #

  5. gswartz
    Member
    Posted 2 years ago #

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

  6. gswartz
    Member
    Posted 2 years ago #

    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]

  7. esmi
    Forum Moderator
    Posted 2 years ago #

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

  8. gswartz
    Member
    Posted 2 years ago #

    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.

  9. gswartz
    Member
    Posted 2 years ago #

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

  10. esmi
    Forum Moderator
    Posted 2 years ago #

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

  11. gswartz
    Member
    Posted 2 years ago #

    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?

  12. esmi
    Forum Moderator
    Posted 2 years ago #

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

  13. gswartz
    Member
    Posted 2 years ago #

    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

  14. esmi
    Forum Moderator
    Posted 2 years ago #

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

  15. gswartz
    Member
    Posted 2 years ago #

    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>

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic