Archived topic
Hide post in category
9 replies · Started by Jaime on July 2, 2018
Appreciated
Have an excellent day
I need to hide the posts in the category files. I just want to see only the category page, without the related entries and paging-navigation.
Could you please supply me with a code for that purpose?
I was already exploring in the forum and I found this but I do not know how to accommodate my needs
add_filter('pre_get_posts', 'excludeCat');
function excludeCat($query) {
if ( $query->is_home ) {
$query->set('cat', '-3,-5,-23');
}
return $query;
}
First of all, Thanks
Hi there,
I'm not too sure what you mean. Are you wanting the page to display nothing when you go to a specific category?
Thanks tom
Please excuse my English
What I want to do hide the entries of the categories as in image No 2
It could be done with a plugin, but I would like to do it through code.
Thank you again
Img No 1

Img No 2

In all categories...
This CSS should work:
.category article {
display: none;
}
Let me know :)
Hi Tom, I would like you not to be seen in the source code.
Would a solution in php be possible?
And hide also the page-numbers.
Although I think that if the entries are hidden by php, the page-numbers will not appear
Greetings and Thank you
In category.php remove the loop.
Yea, in that case you would need to copy archive.php in the parent theme, and add it to your child theme.
Then re-name it to category.php.
Once you do that, remove this section from the file: https://github.com/tomusborne/generatepress/blob/2.1.3/archive.php#L35-L46
All prefect
Gives the query resolved
Thank you very much
You're welcome :)