Filter posts category page

Posted in: Newspaper
Post count: 2

Hi, i’ve some categories created and i can view post from them loading them page (category.php)

I want to exlude some posts (for example with some tags) from default category view. Is it possible? (changing loop.php?)

I can compose a specific page for each category…but i have enough of them.

Thanks a lot!

Post count: 20688

Hi,

You could try the solution provided in this topic, to exclude posts with specific tags from the category pages
https://forum.tagdiv.com/topic/exclude-posts-on-category-with-certain-tags/
Use your own tag Id’s in the code, and see if it works for you.

Thanks

Post count: 2

Hi, thanks a lot.

It’s working, but it affects all the queries. I want to add a second loop in category.php to show posts not included in first loop. For example, in the main loop show posts with tag_id 32, and second loop show posts without tag_id 32.

When i add your action to functions php…only filtered posts are loaded.

Could it be possible?

My code in category.php is:
$args1 = array(
'cat' => $current_category_id,
'tag_id' => 32
);

$query1 = new WP_Query($args1);

while ( $query1->have_posts() ) {
$query1->the_post();
echo '

  • ' . get_the_title() . '
  • ';
    }

    Thanks a lot!

    Post count: 20688

    Hi,

    I don’t have a solution for adding a second loop for the categories. This level of implementation will have to be made custom and it probably means a lot of work to do and test. Maybe you should consider hiring a freelancer to help you with this kind of customization, because we cannot provide custom work at the moment, sorry.
    Or try to do it yourself and test it. Search for similar topics like this one
    https://stackoverflow.com/questions/3456006/adding-a-second-loop-to-a-wordpress-theme-on-a-separate-page

    Thanks

    Viewing 4 posts - 1 through 4 (of 4 total)
    The forum ‘Newspaper’ is closed to new topics and replies.