Home › Forums › Basel support forum › Replace page category "All", in shop page
Replace page category "All", in shop page
- This topic has 7 replies, 2 voices, and was last updated 7 years, 2 months ago by Artem Temos.
-
AuthorPosts
-
October 22, 2017 at 5:43 pm #22266
hcavesParticipantHello!
Due to my small number of products, I would like to replace the Category “All” from my website.
I’m talking for example about this page: Shop page
Instead of the tab “All”, that shows all the products, I would like to display a custom page.Do you know how this is achievable?
Thank you in advance!
October 22, 2017 at 6:37 pm #22270
Artem TemosKeymasterHello,
You can do this only with additional customization of template PHP file. This link is located in the file
inc/woocommerce.php
. PHP function name –basel_product_categories_nav
.Regards
October 23, 2017 at 8:27 pm #22357
hcavesParticipantThanks for the answer.
So here is what I’ve done: thanks to the pluggable function you created in the theme, I copy pasted the function in the child theme, to change what I need to change.
To achieve my objective, I can replace the variable shop_link with
$shop_link = get_permalink($post = 1750, $leavename = false );
With $post = the page id I want.But this is not a very smooth: the page starts loading as ajax, then redirects…
I would like to be able to display the content I want under the “All” tab, with keeping the same experience (no page reload, but the loading icon), and keep the Heading bar with the category name.
I understand this is tricky, but is it achievable?
Otherwise, is it possible to deactivate the loading icon, and directly go the page after clicking on “All”?
Thank you!
October 24, 2017 at 6:25 am #22382
Artem TemosKeymasterCould you please write us the function you have at the moment so we can check what is wrong? Or at least lines with your changes (20-30 lines of code).
Regards
October 24, 2017 at 7:53 am #22401
hcavesParticipantI actually only did one change: I changed the variable value $shop_link.
But it doesn’t really make sense, as I give the link to a full new page. I shouldn’t, right? I should have something with just content, I mean no menu, no page heading, etc, as when I navigate between categories thanks to the page heading of the template.
function basel_product_categories_nav() { global $wp_query, $post; $show_subcategories = basel_get_opt( 'shop_categories_ancestors' ); $list_args = array( 'taxonomy' => 'product_cat', 'hide_empty' => false ); // Menu Order $list_args['menu_order'] = false; $list_args['menu_order'] = 'asc'; // Setup Current Category $current_cat = false; $cat_ancestors = array(); if ( is_tax( 'product_cat' ) ) { $current_cat = $wp_query->queried_object; $cat_ancestors = get_ancestors( $current_cat->term_id, 'product_cat' ); } $list_args['depth'] = 5; $list_args['child_of'] = 0; $list_args['title_li'] = ''; $list_args['hierarchical'] = 1; $list_args['use_desc_for_title']= false; $shop_link = get_permalink($post = 1750, $leavename = false ); include_once( WC()->plugin_path() . '/includes/walkers/class-product-cat-list-walker.php' ); echo '<a href="#" class="basel-show-categories">' . __('Categories', 'basel') . '</a>'; echo '<ul class="basel-product-categories">'; echo '<li class="cat-link shop-all-link"><a href="' . esc_url( $shop_link ) . '">' . __('My custom label', 'basel') . '</a></li>'; if( $show_subcategories ) { basel_show_category_ancestors(); } else { wp_list_categories( $list_args ); } echo '</ul>'; }
October 24, 2017 at 8:14 am #22405
Artem TemosKeymasterSorry, we got the problem. Yes, it will not be compatible with AJAX shop functionality and you can’t exclude only this link. So you may disable AJAX shop or remove this ALL link at all.
Regards
October 24, 2017 at 8:15 am #22406
hcavesParticipantOk, I got it as well.
I will define what’s the best solution for me.
Thank you!
October 24, 2017 at 8:34 am #22408
Artem TemosKeymasterOK, contact us if you will have any additional questions.
-
AuthorPosts
- You must be logged in to create new topics. Login / Register