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.
Tagged:
Comments
@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 itsingle-product.php
. See this: https://codex.wordpress.org/Post_Type_Templates . There may also be aget_sidebar()
call in thesingle-product.php
file. Change that toget_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 itsidebar-shop.php
. Insidesidebar-shop.php
, there may be a call todynamic_sidebar(...);
Change that todynamic_sidebar("shop_sidebar");
Now register your shop sidebar by opening your
functions.php
file of your theme and adding theregister_sidebar();
code to it. See this documentation: https://codex.wordpress.org/Function_Reference/register_sidebar . Once you've added theregister_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/