Sidebar on product page

I'm trying to specify what sidebar appears on a product page for the shopping cart. I can't seem to come up with the right conditional logic. The pages is /product/full-page-advertisement/

So, I tried:

if (in_category("product"))

But that didn't work.

Any ideas? I don't see any setting to specify the sidebar for all cart-related pages.

Comments

  • 1 Comment sorted by
  • Vote Up0Vote Down
    edited May 2015

    @elsiegilmore

    Thank you for your post.

    I see that you're using the /product/ custom post type for your Shopping Cart plugin products. That makes it easy to create a custom post type template and register a sidebar for that post type.

    So first, create a custom post type template by making a copy of single.php in your WordPress theme and name it single-product.php. See this: https://codex.wordpress.org/Post_Type_Templates . There may also be a get_sidebar() call in the single-product.php file. Change that to get_sidebar("shop");

    Now go and create a sidebar template file for the shop by making a copy of sidebar.php in your WordPress theme and naming it sidebar-shop.php. Inside sidebar-shop.php, there may be a call to dynamic_sidebar(...); Change that to dynamic_sidebar("shop_sidebar");

    Now register your shop sidebar by opening your functions.php file of your theme and adding the register_sidebar(); code to it. See this documentation: https://codex.wordpress.org/Function_Reference/register_sidebar . Once you've added the register_sidebar() code with custom arguments to create the "shop_sidebar" (the ID of the sidebar), you can go to Appearance > Widgets and the new sidebar will be there to put widgets on it.

    Let me know if this helps and if you want us to do this for you. If you do, please submit a ticket with WordPress and FTP login details to our help desk: http://tribulant.com/support/

Sign In or Register to comment.