• Resolved zv664013

    (@zv664013)


    Hello all,

    I’m constructing a site that allows startups to apply their new company to be considered for seed funding from local angel investors. To do this, I allow registered users to submit all needed information from a front-end post submission form that I either approve or deny. I’ve added code to my single.php file to automatically add a contact form to the bottom of the submitted post that will be sent to the post authors email address (hence why users must register before submission). My problem is that I want to hide this contact form from the “news” category posts and only have it display in the “startups” category posts. These are the only 2 categories I’ll be using on the site. Below is the code I’ve added to my single.php file to automatically insert the contact form in all posts. (note I’m using contact form 7)

    <div class=”email”><h3><span style=”color: #c0392b;”>Send this startup a message using the form below.
    All fields are required.</span></h3>

    <?php echo do_shortcode( ‘[contact-form-7 id=”21″ title=”Contact form 1″]’ ); ?></div>

Viewing 1 replies (of 1 total)
  • Thread Starter zv664013

    (@zv664013)

    Nevermind, figured it out. Simply copied the single.php into 2 different php files: one named single_news.php and single_default.php.

    Then stripped the code from single.php and put this in it’s place

    <?php get_header(); ?>

    <?php
    if ( have_posts() ) { }
    if ( in_category(4) ) {
    include(TEMPLATEPATH . ‘/single_news.php’);
    }
    else {
    include(TEMPLATEPATH . ‘/single_default.php’);
    }
    ?>

    <?php get_footer(); ?>

    Then I was able to delete the <?php echo do_shortcode( ‘[contact-form-7 id=”21″ title=”Contact form 1″]’ ); ?> from the single_news.php file

Viewing 1 replies (of 1 total)
  • The topic ‘Hiding a div from all posts within a certain category’ is closed to new replies.