Jump to content

Archived

This topic is now archived and is closed to further replies.

NBI

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

Recommended Posts

NBI    0
NBI

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
Danny    1,327
Danny

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.

  • Like 2

Please search our forums, before posting!

Share this post


Link to post
Share on other sites
Danny    1,327
Danny

No problem.


Please search our forums, before posting!

Share this post


Link to post
Share on other sites

  • Similar Content

    • JP
      By JP+
      Hello,
      We are working on a 2 languages site (https://liguecardioliga.be) with wpml, and lately the call of a category in the loops section (and all the sections requiring a category to select posts) doesn't work in the translated language. It worked well until recently so I wonder if it's because of a recent update (wordpress, wpml, pagelines, a plugin?). Anyone has the same problem? a solution?
      TIA
    • Queue-it
      By Queue-it+
      Hi,
      Previous webmaster has made short codes assigned to certain categories. For example: [pl_section section="loops" id="003"]  displays all the Job posts for tech. 
      But where can I assign a short code for a certain category? I can't find where to add the loop ID for the category.
       
      Thank you
       
    • Queue-it
      By Queue-it+
      I've created a new post category "Success stories" with Custom Post type UI. (in order to have a different layout for a different post category - blog post one layout, success stories another layout).
      New category "success stories" are "detached" from all the other posts, so they have a different layout, but the problem is that all of the success stories are also having the same exact content.
      So whenever I edit content (e.g. change body text) on one of success story posts, it also changes the content (body text) for all other Success story category posts. 
       
      Question: Is there a way to retain this separate category with it's own layout, and have a different content for each individual post? I'm using Pagelins templates. 
       Thanks in advance.
    • Queue-it
      By Queue-it+
      Hi,
      Is is possible to have different layouts for different Post categories? We have Blog posts, News posts and Case studies that all are posts, but is it possible to differentiate their layouts?
      So far when I change a post layout it affects all Post type pages. Could it be done somehow with creating a separate template? 
      Examples below
      https://queue-it.com/news/
      https://queue-it.com/blog/
       
    • Queue-it
      By Queue-it+
      Hi,
      Do you know how to hide a container background image only mobile?
      I've tried all the possible versions with .@media display hide [pl_uploads_url]/2016/10/image.png    but it would hide all container not just the image. 
       
×