0

Currently, there is a sidebar dedicated to all posts, and one for all pages. What I would like to do is target specific page templates to display sidebars for each template.

if(is_front_page())
            {
              if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar("Blog Sidebar") ) :
              endif;

            }
            else if(get_post_type($post) == "post" || is_search()  )
            {
              if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar("Blog Sidebar") ) :
              endif;

            }
            else if((get_post_type($post) != "post" && get_post_type($post) != "page") || get_post_type() == "")
            {
              if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar("Portfolio Sidebar") ) :
              endif;

            }
            else if(get_post_type($post) == "page" || is_author() || is_404() )
            {
              if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar("Page Sidebar") ) :
              endif;

            }

So instead of posting "Page Sidebar" for all of the pages. I would like to target, for example, the products.php template so that I can put a specific sidebar for those pages.

I have added into functions, additional dynamic_sidebars but I need to find a way to target them on this sidebar.php.

IF you need more info please let me know

0

WordPress is very accommodating when it comes to conditionals:

if (is_page_template('products.php')) {
...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.