WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Contact Form 7 - Special Tags inside the template (5 posts)

  1. Patrick
    Member
    Posted 2 years ago #

    For the special mail tags fetching [_post_*] data to work they must be inside the post / page's content.

    However, my form is in the template files. Is there any way to use the [_post_*] when the form is outside of the the_content ?

    Thanks!

  2. Takayuki Miyoshi
    Member
    Posted 2 years ago #

  3. Patrick
    Member
    Posted 2 years ago #

    I use my form inside an if statement, so I placed it before the endwhile; ?>` and it works fine - but the [_post_title] mail tag still doesn't work.

    Any idea why?

    This is ewhat I have:

    <?php
    						if ( have_posts() ) while ( have_posts() ) : the_post();
    							echo'<h3><a href="' . get_permalink() . '" rel="bookmark">'.get_the_title($post->ID).'</a></h3>' ;
    
    							echo the_content();
    						endwhile; 
    
    						if( in_category('special-offers') ) : ?>
    <p>Apply for this offer by filling out the simple enquiry form below and we will be in touch shortly.</p><!-- this is a html section -->
    <?php echo do_shortcode( '[contact-form 3 "Spcial Offers"]' ); ?>
    <?php else :
    /*php for other*/
    endif;
    						?>

    Thanks again!

  4. Takayuki Miyoshi
    Member
    Posted 2 years ago #

    You placed <?php echo do_shortcode( '[contact-form 3 "Spcial Offers"]' ); ?> after the endwhile ?

  5. Patrick
    Member
    Posted 2 years ago #

    Sorry forgot to update!

    Worked a treat, thanks!

Topic Closed

This topic has been closed to new replies.

About this Topic