Hide sub category titles on single parent sub category archive page WooCommerce
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
I'm building a WP ecommerce site with multiple categories & sub-categories and need to remove the sub-category titles on just one archive page (slug = 'paving-brands'):
http://redyearclients.co.uk/PandF/product-category/exterior-paving/paving-brands/
All other category & sub category pages still require the sub category titles, this page for example should remain as it is now:
http://redyearclients.co.uk/PandF/product-category/exterior-paving/paving-stone-types/
Many thanks.
php wordpress woocommerce hook-woocommerce
add a comment |
I'm building a WP ecommerce site with multiple categories & sub-categories and need to remove the sub-category titles on just one archive page (slug = 'paving-brands'):
http://redyearclients.co.uk/PandF/product-category/exterior-paving/paving-brands/
All other category & sub category pages still require the sub category titles, this page for example should remain as it is now:
http://redyearclients.co.uk/PandF/product-category/exterior-paving/paving-stone-types/
Many thanks.
php wordpress woocommerce hook-woocommerce
Are you okay with using css? Try this.archive.term-paving-brands category-name { display: none; }. This should hide all category titles on paving brands page.
– Bariel R.
Oct 3 '16 at 12:30
add a comment |
I'm building a WP ecommerce site with multiple categories & sub-categories and need to remove the sub-category titles on just one archive page (slug = 'paving-brands'):
http://redyearclients.co.uk/PandF/product-category/exterior-paving/paving-brands/
All other category & sub category pages still require the sub category titles, this page for example should remain as it is now:
http://redyearclients.co.uk/PandF/product-category/exterior-paving/paving-stone-types/
Many thanks.
php wordpress woocommerce hook-woocommerce
I'm building a WP ecommerce site with multiple categories & sub-categories and need to remove the sub-category titles on just one archive page (slug = 'paving-brands'):
http://redyearclients.co.uk/PandF/product-category/exterior-paving/paving-brands/
All other category & sub category pages still require the sub category titles, this page for example should remain as it is now:
http://redyearclients.co.uk/PandF/product-category/exterior-paving/paving-stone-types/
Many thanks.
php wordpress woocommerce hook-woocommerce
php wordpress woocommerce hook-woocommerce
asked Oct 3 '16 at 12:22
Red YearRed Year
255
255
Are you okay with using css? Try this.archive.term-paving-brands category-name { display: none; }. This should hide all category titles on paving brands page.
– Bariel R.
Oct 3 '16 at 12:30
add a comment |
Are you okay with using css? Try this.archive.term-paving-brands category-name { display: none; }. This should hide all category titles on paving brands page.
– Bariel R.
Oct 3 '16 at 12:30
Are you okay with using css? Try this
.archive.term-paving-brands category-name { display: none; }. This should hide all category titles on paving brands page.– Bariel R.
Oct 3 '16 at 12:30
Are you okay with using css? Try this
.archive.term-paving-brands category-name { display: none; }. This should hide all category titles on paving brands page.– Bariel R.
Oct 3 '16 at 12:30
add a comment |
1 Answer
1
active
oldest
votes
Update - Nov 2018
The easiest way for that purpose is to make a custom conditional function that you will use in the concerned related template
content-product_cat.phpwhere the this subcategory title is hooked.
1) The conditional function
Here is that code:
function is_parent_category( $subcategory_term, $parent_category_term_slug ) {
$parent_term = get_term( $subcategory_term->parent, $subcategory_term->taxonomy );
return $parent_term->slug == $parent_category_term_slug ? true : false;
}
This code goes in function.php file of your active child theme (or theme) or also in any plugin file.
2) Overriding via your theme **content-product_cat.php WooCommerce template.**
If not done yet, inside your active child theme (or theme) create a
woocommercefolder. Then copy fromwoocommerceplugintemplatesfolder a file namedcontent-product_cat.phpinside the fresh createdwoocommercefolder in your active child theme (or theme).
The open/edit this copied content-product_cat.php template file.
Replace the following line:
do_action( 'woocommerce_shop_loop_subcategory_title', $category );
By this:
if( ! is_parent_category( $category, 'exterior-paving' ) ) {
do_action( 'woocommerce_shop_loop_subcategory_title', $category );
}
Save, you are done. Now as you wished, all the brand titles only on the 'paving-brands' archive page will be removed.
This code is tested and fully functional.
ADDITION: Handling Multiple parent category slugs:
To handle multiple parent category slugs use the following instead (from an array of slugs):
function is_parent_category( $subcategory_term, $parent_category_term_slugs ) {
$parent_term = get_term( $subcategory_term->parent, $subcategory_term->taxonomy );
return in_array($parent_term->slug, $parent_category_term_slug ) ? true : false;
}
USAGE example:
// Reminder: $category is a WP_Term object
if ( is_parent_category( $category, array( 'clothing', 'posters' ) ) {
// Do something (matching subcategory)
} else {
// Do something else (no matching subcategory)
}
Thank you so much, really appreciate the help.
– Red Year
Oct 3 '16 at 14:35
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f39831556%2fhide-sub-category-titles-on-single-parent-sub-category-archive-page-woocommerce%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Update - Nov 2018
The easiest way for that purpose is to make a custom conditional function that you will use in the concerned related template
content-product_cat.phpwhere the this subcategory title is hooked.
1) The conditional function
Here is that code:
function is_parent_category( $subcategory_term, $parent_category_term_slug ) {
$parent_term = get_term( $subcategory_term->parent, $subcategory_term->taxonomy );
return $parent_term->slug == $parent_category_term_slug ? true : false;
}
This code goes in function.php file of your active child theme (or theme) or also in any plugin file.
2) Overriding via your theme **content-product_cat.php WooCommerce template.**
If not done yet, inside your active child theme (or theme) create a
woocommercefolder. Then copy fromwoocommerceplugintemplatesfolder a file namedcontent-product_cat.phpinside the fresh createdwoocommercefolder in your active child theme (or theme).
The open/edit this copied content-product_cat.php template file.
Replace the following line:
do_action( 'woocommerce_shop_loop_subcategory_title', $category );
By this:
if( ! is_parent_category( $category, 'exterior-paving' ) ) {
do_action( 'woocommerce_shop_loop_subcategory_title', $category );
}
Save, you are done. Now as you wished, all the brand titles only on the 'paving-brands' archive page will be removed.
This code is tested and fully functional.
ADDITION: Handling Multiple parent category slugs:
To handle multiple parent category slugs use the following instead (from an array of slugs):
function is_parent_category( $subcategory_term, $parent_category_term_slugs ) {
$parent_term = get_term( $subcategory_term->parent, $subcategory_term->taxonomy );
return in_array($parent_term->slug, $parent_category_term_slug ) ? true : false;
}
USAGE example:
// Reminder: $category is a WP_Term object
if ( is_parent_category( $category, array( 'clothing', 'posters' ) ) {
// Do something (matching subcategory)
} else {
// Do something else (no matching subcategory)
}
Thank you so much, really appreciate the help.
– Red Year
Oct 3 '16 at 14:35
add a comment |
Update - Nov 2018
The easiest way for that purpose is to make a custom conditional function that you will use in the concerned related template
content-product_cat.phpwhere the this subcategory title is hooked.
1) The conditional function
Here is that code:
function is_parent_category( $subcategory_term, $parent_category_term_slug ) {
$parent_term = get_term( $subcategory_term->parent, $subcategory_term->taxonomy );
return $parent_term->slug == $parent_category_term_slug ? true : false;
}
This code goes in function.php file of your active child theme (or theme) or also in any plugin file.
2) Overriding via your theme **content-product_cat.php WooCommerce template.**
If not done yet, inside your active child theme (or theme) create a
woocommercefolder. Then copy fromwoocommerceplugintemplatesfolder a file namedcontent-product_cat.phpinside the fresh createdwoocommercefolder in your active child theme (or theme).
The open/edit this copied content-product_cat.php template file.
Replace the following line:
do_action( 'woocommerce_shop_loop_subcategory_title', $category );
By this:
if( ! is_parent_category( $category, 'exterior-paving' ) ) {
do_action( 'woocommerce_shop_loop_subcategory_title', $category );
}
Save, you are done. Now as you wished, all the brand titles only on the 'paving-brands' archive page will be removed.
This code is tested and fully functional.
ADDITION: Handling Multiple parent category slugs:
To handle multiple parent category slugs use the following instead (from an array of slugs):
function is_parent_category( $subcategory_term, $parent_category_term_slugs ) {
$parent_term = get_term( $subcategory_term->parent, $subcategory_term->taxonomy );
return in_array($parent_term->slug, $parent_category_term_slug ) ? true : false;
}
USAGE example:
// Reminder: $category is a WP_Term object
if ( is_parent_category( $category, array( 'clothing', 'posters' ) ) {
// Do something (matching subcategory)
} else {
// Do something else (no matching subcategory)
}
Thank you so much, really appreciate the help.
– Red Year
Oct 3 '16 at 14:35
add a comment |
Update - Nov 2018
The easiest way for that purpose is to make a custom conditional function that you will use in the concerned related template
content-product_cat.phpwhere the this subcategory title is hooked.
1) The conditional function
Here is that code:
function is_parent_category( $subcategory_term, $parent_category_term_slug ) {
$parent_term = get_term( $subcategory_term->parent, $subcategory_term->taxonomy );
return $parent_term->slug == $parent_category_term_slug ? true : false;
}
This code goes in function.php file of your active child theme (or theme) or also in any plugin file.
2) Overriding via your theme **content-product_cat.php WooCommerce template.**
If not done yet, inside your active child theme (or theme) create a
woocommercefolder. Then copy fromwoocommerceplugintemplatesfolder a file namedcontent-product_cat.phpinside the fresh createdwoocommercefolder in your active child theme (or theme).
The open/edit this copied content-product_cat.php template file.
Replace the following line:
do_action( 'woocommerce_shop_loop_subcategory_title', $category );
By this:
if( ! is_parent_category( $category, 'exterior-paving' ) ) {
do_action( 'woocommerce_shop_loop_subcategory_title', $category );
}
Save, you are done. Now as you wished, all the brand titles only on the 'paving-brands' archive page will be removed.
This code is tested and fully functional.
ADDITION: Handling Multiple parent category slugs:
To handle multiple parent category slugs use the following instead (from an array of slugs):
function is_parent_category( $subcategory_term, $parent_category_term_slugs ) {
$parent_term = get_term( $subcategory_term->parent, $subcategory_term->taxonomy );
return in_array($parent_term->slug, $parent_category_term_slug ) ? true : false;
}
USAGE example:
// Reminder: $category is a WP_Term object
if ( is_parent_category( $category, array( 'clothing', 'posters' ) ) {
// Do something (matching subcategory)
} else {
// Do something else (no matching subcategory)
}
Update - Nov 2018
The easiest way for that purpose is to make a custom conditional function that you will use in the concerned related template
content-product_cat.phpwhere the this subcategory title is hooked.
1) The conditional function
Here is that code:
function is_parent_category( $subcategory_term, $parent_category_term_slug ) {
$parent_term = get_term( $subcategory_term->parent, $subcategory_term->taxonomy );
return $parent_term->slug == $parent_category_term_slug ? true : false;
}
This code goes in function.php file of your active child theme (or theme) or also in any plugin file.
2) Overriding via your theme **content-product_cat.php WooCommerce template.**
If not done yet, inside your active child theme (or theme) create a
woocommercefolder. Then copy fromwoocommerceplugintemplatesfolder a file namedcontent-product_cat.phpinside the fresh createdwoocommercefolder in your active child theme (or theme).
The open/edit this copied content-product_cat.php template file.
Replace the following line:
do_action( 'woocommerce_shop_loop_subcategory_title', $category );
By this:
if( ! is_parent_category( $category, 'exterior-paving' ) ) {
do_action( 'woocommerce_shop_loop_subcategory_title', $category );
}
Save, you are done. Now as you wished, all the brand titles only on the 'paving-brands' archive page will be removed.
This code is tested and fully functional.
ADDITION: Handling Multiple parent category slugs:
To handle multiple parent category slugs use the following instead (from an array of slugs):
function is_parent_category( $subcategory_term, $parent_category_term_slugs ) {
$parent_term = get_term( $subcategory_term->parent, $subcategory_term->taxonomy );
return in_array($parent_term->slug, $parent_category_term_slug ) ? true : false;
}
USAGE example:
// Reminder: $category is a WP_Term object
if ( is_parent_category( $category, array( 'clothing', 'posters' ) ) {
// Do something (matching subcategory)
} else {
// Do something else (no matching subcategory)
}
edited Nov 17 '18 at 4:53
answered Oct 3 '16 at 12:40
LoicTheAztecLoicTheAztec
98.4k1472114
98.4k1472114
Thank you so much, really appreciate the help.
– Red Year
Oct 3 '16 at 14:35
add a comment |
Thank you so much, really appreciate the help.
– Red Year
Oct 3 '16 at 14:35
Thank you so much, really appreciate the help.
– Red Year
Oct 3 '16 at 14:35
Thank you so much, really appreciate the help.
– Red Year
Oct 3 '16 at 14:35
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f39831556%2fhide-sub-category-titles-on-single-parent-sub-category-archive-page-woocommerce%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Are you okay with using css? Try this
.archive.term-paving-brands category-name { display: none; }. This should hide all category titles on paving brands page.– Bariel R.
Oct 3 '16 at 12:30