[Support request] I don't want to show the posts in the category pages.

Home Forums Support [Support request] I don't want to show the posts in the category pages.

Home Forums Support I don't want to show the posts in the category pages.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #768321
    Fernando

    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!

    #768615
    Tom
    Lead Developer
    Lead Developer

    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

    #769711
    Fernando

    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… 🙁

    #769990
    Tom
    Lead Developer
    Lead Developer

    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.

    #784479
    Fernando

    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.

    #784774
    David
    Staff
    Customer Support

    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.

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.