[Support request] Hide post in category

Home Forums Support [Support request] Hide post in category

Home Forums Support Hide post in category

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #613785
    Jaime

    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

    #613893
    Tom
    Lead Developer
    Lead Developer

    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?

    #615449
    Jaime

    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

    Image No 1

    Img No 2

    Image No 2

    #615462
    Jaime

    In all categories…

    #615751
    Tom
    Lead Developer
    Lead Developer

    This CSS should work:

    .category article {
        display: none;
    }

    Let me know ๐Ÿ™‚

    #617661
    Jaime

    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

    #617700
    Anil

    In category.php remove the loop.

    #617718
    Tom
    Lead Developer
    Lead Developer

    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

    #617898
    Jaime

    All prefect

    Gives the query resolved

    Thank you very much

    #617899
    Tom
    Lead Developer
    Lead Developer

    You’re welcome ๐Ÿ™‚

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