-
AuthorPosts
-
December 12, 2015 at 1:40 pm #704162
Hi Richard,
Ah, you’re trying to exclude them from the widget, and not from the blog posts. And please don’t mix up jQuery coding and PHP Coding. jQuery goes to customizer’s custom javascript, while PHP goes directly to child theme templates and functions.php
Please change your code to this,
add_filter( 'widget_categories_args', 'wpsites_exclude_widget_category', 99 ); add_filter( 'widget_categories_dropdown_args', 'wpsites_exclude_widget_category', 99 ); function wpsites_exclude_widget_category( $cat_args ) { $cat_args['exclude'] = '11'; return $cat_args; }
Thanks, and please clear your cache before testing.
December 13, 2015 at 5:58 am #704697Hi support team,
thanks for your help but i have to say that i don’t notice any difference with the code in post #703825
The archive stills shows a lot of months in which only reviews where placed.see image which shows you as an example the archive of december and on the right hand side i have a screenshot of the post which is a review.
Thanks again
December 13, 2015 at 1:51 pm #705051Hi Richard,
Sorry for the confusion, the code provided will only exclude the category from widgets, and for categories only (not dates).
It’s not effective for widget archives, they are not categories, they are just date. And the code as no effect for month archive pages either, because it’s not category nor a widget.
I’m not really sure what you’re trying to do, maybe it’s best to provide a video recording 🙂
Though, this is not part of X, it’s rather wordpress customization. I can’t promise a fix or solution, but I’ll try to understand it first 🙂
Thanks!
December 14, 2015 at 4:13 am #705702This reply has been marked as private.December 14, 2015 at 4:45 am #705742Hi,
Thanks for the video.
I now fully understand what you are trying to achieve, regretfully this isn’t a feature offered by X. It could be possible with custom development, but this would be outside the scope of support we can offer. You may wish to consult a developer to assist you with this. X is quite extensible with child themes, so there are plenty of possibilities. Thanks for understanding. Take care!
December 14, 2015 at 6:02 am #705822Found the solution and i want to share this with you and other users of X. Because i can imagine that others want a solution for excluding a certain categorie from the archive month list (archive widget)
Just copy the next code into your child’s php page and put your category ID in the place where now category number 7 is.
Multiple page can be given in with a comma in between them./* exclude categories from category widget */
add_filter(“widget_categories_args”,”exclude_widget_categories”);
function exclude_widget_categories( $args ){
$args[“exclude”] = ‘7’; //multiple = ‘7,8,9’ using IDs from Posts=>Categories page in admin
return $args;
}/* exclude categories from archive list widget */
add_filter(‘getarchives_join’,’customarchives_join’);
add_filter(‘getarchives_where’,’customarchives_where’);
function customarchives_join($x) {
global $wpdb;
return $x.” INNER JOIN $wpdb->term_relationships ON ($wpdb->posts.ID = $wpdb->term_relationships.object_id) INNER JOIN $wpdb->term_taxonomy ON ($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id)”;
}
function customarchives_where($x) {
global $wpdb;
$exclude=’7′; //multiple = ‘7,8,9’ using IDs from Posts=>Categories page in admin
return $x.” AND $wpdb->term_taxonomy.taxonomy = ‘category’ AND $wpdb->term_taxonomy.term_id NOT IN ($exclude)”;
}December 14, 2015 at 6:30 am #705870Thanks for sharing.
Have a great day!
-
AuthorPosts