• 0
Sign in to follow this  
Followers 0

Hide one category/tag from main page, show in another?


Question

Posted · Report post

Hi there,

 

I was wondering if any of you know a way to show posts within a certain category or post on one page as well as hiding that specific post on the main page.

 

For instance:

 

Create a press release category or tag.

Press releases aren't shown on the front page - but everything else is.

On a specific site, the press releases are shown.

 

Thanks in advance for your time!

Share this post


Link to post
Share on other sites

3 answers to this question

  • 0

Posted · Report post

Hi,

 

You can't do that out of the box with the DMS Postloop section. In order to do this you will probably need to use a filter, you can try adding this to your child theme or customize plugins functions.php file (Do not add it to the DMS functions.php file, you will most likely nuke it).

 

function exclude_category($query) {
if ( $query->is_home || $query->is_archive) {
$query->set('cat', '-4');
}
return $query;
}
add_filter('pre_get_posts', 'exclude_category');

 

Replace the -4 in the code to the ID of your category.

2 people like this

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

Thanks for the help, Danny!

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

No problem.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0