Exclude One Category and its Subcategories using WP_LIST_FILTER

I need to exclude a category and its subcategories in posts. This is the code I’m working on and it works: <?php $categories = wp_get_post_terms($post->ID, ‘category’); $categories = wp_list_filter($categories, array(‘slug’=>’regione’), ‘NOT’); $categories = wp_list_filter($categories, array(‘slug’=>’lazio’), ‘NOT’); $categories = wp_list_filter($categories, array(‘slug’=>’rm’), ‘NOT’); if (!empty($categories)) { ?> <ul class=”category”> <?php foreach ($categories as $category) { $cat = … Read more

Exclude post_type from admin comments_list

I’m trying not to show comments from a certain custom post type int the comments list on the admin interface. I went to the “wp-admin/includes/class-wp-comments-list-table.php” and tried to play with the $args array which is passed into the “get_comments” function in order to feed the comments list table. If I add a post_type parameter there … Read more

exclude custom post type by meta key in wp_query

I’m trying to display a custom post type (properties) and exclude posts that have a certain meta value (sold). Is there a way that I can do this? I have this for my code so far: $args = array( ‘post_type’ => ‘property’, ‘orderby’ => ‘meta_value’, ‘meta_key’ => ‘random_775’, ‘order’ => ‘ASC’, ‘posts_per_page’ => 100, ); … Read more

How to exclude categories from recent posts, recent comments & category widgets?

I use the bellow function (thanks to @helgatheviking!) to exclude categories from the wordpress loop. It works very well – posts of selected categories are excluded from the loop on the main blog listing page, from category listing pages and from archives, but not from Recent Posts and not from Recent Comments in sidebar. How … Read more

How to exclude/filter a tag from get_the_tag_list()

Does anyone know how to exclude/filter a tag from the HTML string generated by get_the_tag_list()? http://codex.wordpress.org/Function_Reference/get_the_tag_list Any help much appreciated. 3 Answers 3 function mytheme_filter_tags( $term_links ) { $result = array(); $exclude_tags = array( ‘some tag’, ‘another tag’, ‘third tag’ ); foreach ( $term_links as $link ) { foreach ( $exclude_tags as $tag ) { … Read more

Excluding a category from next and previous post links

I am trying to figure out the code to exclude a category from my next and previous post links. My code for the next and previous is as follows: <div class=”next_prev_cont”> <div class=”left”> <?php previous_post_link(‘%link’, ‘<i>Previous post</i><br />%title’); ?> </div> <div class=”right”> <?php next_post_link(‘%link’, ‘<i>Next post</i><br />%title’); ?> </div> <div class=”clear”></div> </div><!–//next_prev_cont–> I believe I … Read more