change sidebar or just widgets for 2 specific post type single posts

I would like to show a different sidebar for 2 specific posts(same custom post type). I understand how to do this using separate templates for different pages, but I want to have it all happen in the single-posttype.php page. Or am I thinking about this wrong? My end goal is to show different text widgets in the sidebar on specific posts.

3 Answers
3

I think Widget Logic is what you’re looking for. It adds a field to each widget to allow you to specify which post get which widgets. It uses the standard Conditional Tags making it easy to use. You’d just want to do something like

is_single( 'Slug1-or-ID1' ) ||  is_single( 'Slug2-or-ID2' )

You could also try the a post type method to show only a specific post type:

//not tested but something like     
global $post; return ('book' == get_post_type($post));

Leave a Comment