WordPress.org

Forums

WooCommerce - excelling eCommerce
Making Shop base page, category pages, single product pages all different (3 posts)

  1. Seahawksean
    Member
    Posted 1 year ago #

    I'm trying to make the shop page different from the category pages and the single product pages. I've gone ahead and made 3 different templates (single-product.php, archive-product.php, shop-product.php) for each and put them in my theme folder. The single product pages and category pages are laid out just the way I want them after I edited the corresponding templates. However, no matter what I do to the Shop page template (even delete all the code) it has no affect on how the shop page displays. I even tried assigning different templates of my theme (Customizr) to the Shop page in Dashboard > Pages.

    In addition, I want each of these pages to have their own sidebar. So I created 3 sidebar files (sidebar-product.php, sidebar-archive.php, sidebar-shop.php), registered 3 sidebars in my function.php file with the following code:

    /* Woocommerce Sidebars */
    /* Single Product page sidebar */
    register_sidebar( array(
    	'name' => __( 'Single Product Pages Sidebar', 'customizr' ),
    	'id' => 'product-widgets',
    	'description' => __( 'Appears on the single product pages.', 'customizr' ),
            'before_widget' => '<div id="%1$s" class="widget %2$s shop-widgets">',
            'after_widget' => '</div>',
            'before_title' => '<h1 class="widget-title">',
            'after_title' => '</h1>', ) ); 
    
    /* Product Category/Archive/Tag page sidebar */
    register_sidebar( array(
    	'name' => __( 'Category/Archive/Tags Pages Sidebar', 'customizr' ),
    	'id' => 'archive-widgets',
    	'description' => __( 'Appears on the category/archive/shop/tags pages.', 'customizr' ),
            'before_widget' => '<div id="%1$s" class="widget %2$s shop-widgets">',
            'after_widget' => '</div>',
            'before_title' => '<h1 class="widget-title">',
            'after_title' => '</h1>', ) ); 
    
    /* Product Shop page sidebar */
    register_sidebar( array(
    	'name' => __( 'Shop Page Sidebar', 'customizr' ),
    	'id' => 'shop-widgets',
    	'description' => __( 'Appears on the category/archive/shop/tags pages.', 'customizr' ),
            'before_widget' => '<div id="%1$s" class="widget %2$s shop-widgets">',
            'after_widget' => '</div>',
            'before_title' => '<h1 class="widget-title">',
            'after_title' => '</h1>', ) );

    All three of these sidebars show up in Appearance > Widgets as they should. On the Single Product pages and the Category pages, the correct sidebar is used respectively, however on the Shop Page it is displaying the category page sidebar, and again the layout is not correct (ie: it is displaying the Category page layout).

    This would indicate that the shop-product.php is not being called. But I'm not sure what file calls the templates. I've removed and added my own hooks as suggested by Woocommerce codex, and like I said the Category and Single Product page layout are correct. I guess one thing I don't understand is how you can remove hooks from from just the archive-archive.php and NOT the shop-product.php when they use the same hooks and removing them via functions.php file would remove the hooks from all of them and not just the archive-product.php or the shop-product.php individually.

    If anyone has information on this or can lead me in the right direction I would be greatly appreciative.

    This is the link to my site. http://www.biologydesign.com/SarahCHanson which may help you understand what I'm trying to explain.

    Thank you in advance for your help.

    http://wordpress.org/plugins/woocommerce/

  2. webmixer
    Member
    Posted 11 months ago #

    Hello,

    Is this only the code which you have paste in function.php file or you have create any other code and paste in sidebar.php file. Because i new to wordpress and also wants the same. I want all different sidebars on shop-page and product category page and single product page.

    I copied your code to my function.php file it occurs an error and my wordpress backend doesn't work.

    Can you please help?

    Thank you

  3. Watch Teller
    Member
    Posted 11 months ago #

    @Seahawksean,

    Use Widget Context OR Widget Logic to show or hide different widget in your sidebar by provided checkbox (pages/posts) or URL by Category/Single Product. I personally tried both, used widget context plugin because users friendly of admin ui.

    Another alternative was woosidebar plugin (it is possible to choose under which conditions the sidebar is replaced with the custom sidebar).

    Good Luck ^.^

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • WooCommerce - excelling eCommerce
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic