Archived topic
I don't want to show the posts in the category pages.
5 replies · Started by Fernando on December 29, 2018
I would like to know if there is any way (other than hide them by CSS), not to show the entries in the pages of the categories.
This I want to do because I have a design (made with Elementor) which I insert as a Hook in "Elements".
The problem is that also appear the post that shows Generatepress.
Thank you very much!
Hi there,
There are a couple options.
1. Set up 301 redirects from your category archives to your pages.
2. Do something like this: https://generatepress.com/forums/topic/replace-default-post-category-template-with-a-blank-page-template/#post-608201
Option 1 definitely doesn't.
Option 2 I thank you, but I don't understand it.
How can I show a blank page in the template of the categories?
Another option is to give a better style to the blog entries. Since we don't like a lot of people... :(
Basically, you would add this function to your site:
add_filter('request', function(array $query_vars) {
// do nothing in wp-admin
if (is_admin() ) {
return $query_vars;
}
// if the query is for a category
if ( isset( $query_vars['category_name'] ) ) {
// save the slug
$pagename = $query_vars['category_name'];
// completely replace the query with a page query
$query_vars = array( 'pagename' => "$pagename" );
}
return $query_vars;
} );
What this does is check the category name being requested, and redirects you to the page with that name.
So if I'm landing on mywebsite.com/category/test-category, it will redirect me to mywebsite.com/test-category.
Hi Tom,
This isn't working. Besides, I don't want to redirect to pages with the same name.
I have a design (made with Elementor) which I insert as a Hook in “Elements”. This replaces the style of the category, inserting the template that I have made in Elementor.
The problem is that the posts of each category are still shown, so what I have to do is hide them by CSS, but I wish they could be hidden in another way...
I know this is complicated, but it wouldn't be necessary if the category entries could be edited in GeneratePress as Elementor pages to give it a better style.
Hi there,
if you have Elementor Pro then you can build the Archive Templates with that and it will replace the GP Archives. Alternatively if you can share a link to your site we can have a look to see if its easy enough to replicate in GP.