• BUT only if that post is in a specific category.

    Is this possible?

    I’ve used the template hierarchy to display a custom template when looking at the Category page for all of my “Press” posts. But clicking on an individual post still loads the single.php template. I’d like WordPress to display a new, custom template if that Single Post is in the “Press” category and the default Single.php template if it is anything else.

    Could someone point me in the right direction of figuring this out? I’ve been reading about conditional tags and Category templates for a while but I feel even more confused. Thanks!

    Also,
    I tried an if statement, but it wrecks my page. I’m a little remedial with php and code and etc. I want it to display this code instead of the sidebar if the Single Post is in a Certain Category (66, 67 or 68) but to just load the normal sidebar if the post is in any other category.

    What am I doing wrong?

    This is what I tried, at the bottom of the page, after the post is listed:

    <?php endwhile; else: ?>
    
    <p>Sorry, no posts matched your criteria.</p>
    
    <?php endif; ?>
    
    </div>
    
    <?php if( is_category(array(66,67,68)) {echo '<div id="presssidebar"><p class="about_person_name">Press Room</p>
    <p class="namendate2">Welcome to the press room.  Take information for review purposes or set up a meeting with our founder to learn more about our company. Thanks!.</p>
    <p><ul><li><a href="#company description">What We Do</a></li><li><a href="#timeline">History/Timeline</a></li><li><a href="#pressreleases">Press Releases</a></li><li><a href="#inthenews">In The News…</a></li><li><a href="https://www.nileguide.com/pages/team.html">The Team and Board of Directors</a></li>
    </ul></p>
    </div>'; } else {get_sidebar();} ?>
    
    <?php get_footer(); ?>
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Trying to get a single post to display a specific template…’ is closed to new replies.