Digital experiences for all disciplines
New Landing › How can we help? › Themeforest Theme Support › Clique › Excluding category
New Landing › How can we help? › Themeforest Theme Support › Clique › Excluding category
- This topic has 19 replies, 4 voices, and was last updated 7 years by David Martin – Support.
-
Posted in: Clique
-
September 30, 2015 at 3:37 pm #217614
How do I exclude a category from showing in the portfolio?
I’ve tried changing stuff around in the WP_Query, but I can’t seem to get the regular category exclude to work.Here’s the query:
// PORTFOLIO QUERY SETUP
global $post, $wp_query;
$portfolio_args=array(
‘post_type’ => ‘portfolio’,
‘post_status’ => ‘publish’,
‘paged’ => $page,
‘portfolio-category’ => $category_slug,
‘posts_per_page’ => $item_count
);
$portfolio_items = new WP_Query( $portfolio_args )Any tips?
Thanks!September 30, 2015 at 3:57 pm #217623Hi,
Not 100% sure it will work, give a try just add your Portfolio category slugs that you want to exclude in this line.
'terms' => array( 'cat-name' ),
Copy this code below to your functions.php
function search_filter_get_posts($query) { if ( !$query->is_search ) return $query; $taxquery = array( array( 'taxonomy' => 'portfolio-category', 'field' => 'slug', 'terms' => array( 'cat-name' ), 'operator'=> 'NOT IN' ) ); $query->set( 'tax_query', $taxquery ); } add_action( 'pre_get_posts', 'search_filter_get_posts' );
Let us know the result.
-Rui
September 30, 2015 at 4:31 pm #217637Works like a charm! Thanks!
September 30, 2015 at 4:33 pm #217639Great. I’m always afraid of that filter 🙂
-Rui
October 10, 2016 at 3:53 pm #295536It doesn’t work for me!
I created a child theme and added that function to the newly created functions.phpIs it correct?
October 10, 2016 at 4:24 pm #295549Yes, it’s suppose to.
Can you provide me admin credentials to have a look at your functions.php of the child theme?-Rui
October 10, 2016 at 4:31 pm #295551This reply has been marked as private.October 11, 2016 at 2:19 pm #295763This reply has been marked as private.October 11, 2016 at 2:24 pm #295765@theFencer thanks
Looking at your code I can confirm that the slug hall-of-fame doesn’t exist has a portfolio category.https://www.dropbox.com/s/93yh6uv3jeder5d/Screenshot%202016-10-11%2014.23.43.png?dl=0
What are you trying to achieve exactly?
-Rui
October 11, 2016 at 2:39 pm #295772Well, I just wanted to exclude the articles of category hall-of-fame from the blog (menu: news).
Viceversa, I want to leave these articles in the hall of fame menu page.Perhaps the attached screenshots explain better than words…
Attachments:
You must be logged in to view attached files.October 11, 2016 at 2:53 pm #295780ok, the code I provide was to exclude portfolio categories that’s the difference.
I already changed this line of code
'taxonomy' => 'portfolio-category',
to this one
'taxonomy' => 'category',
Check if it works.
-Rui
October 11, 2016 at 2:59 pm #295784Strangely it doesn’t (the article is still visible in both pages).
Should I put this filter somewhere?October 12, 2016 at 3:21 pm #296022Hi Rui, do you have news for me?
October 13, 2016 at 1:01 pm #296234Will need ftp to try some things.
can you send it in a private reply.-Rui
October 13, 2016 at 1:45 pm #296249This reply has been marked as private. -
Posted in: Clique
You must be logged in and have valid license to reply to this topic.