Okay
  Public Ticket #1481493
Blog recent posts
Closed

Comments

  • Rafael started the conversation

    Hi,


    I need to hide my categories from "recents blog posts"

    Any custom CSS for that?

    Thank you guys!

  •  2
    Oryan replied

    Greetings.

    I am unsure if there is a way to do this with CSS; I believe it can be accomplished with Plugins or adding a function by modifying pre-get-post hook within the functions.php file located in the salient theme directory.

    Code:

    if ( $query->is_home ) {
    $query->set( 'cat', '-5, -34' );
    }
    return $query;
    }
     
    add_filter( 'pre_get_posts', 'exclude_category_home' );

    Files may be edited directly through WordPress by going to Appearance -> Editor selecting the chosen theme and navigate to the file within the listing in the right panel.


    Plugin:
    There once was a plugin named 'Simply Exclude' though I do believe it isn't updated regularly.

  • Rafael replied

    Should I paste in any specific line in the functions.php?

  •  2,744
    Andrew replied

    Hey there,

    Thanks for reaching in,

    You could try at the end of the file.

    Regards

  • Rafael replied

    returns


    syntax error, unexpected '}', expecting end of file


  •  2,744
    Andrew replied

    Hey there,

    Thanks for reaching in,

    Please try

    function exclude_category_home( $query ) {
    if ( $query->is_home ) {
    $query->set( 'cat', '-5, -34' );
    }
    return $query;
    }
     
    add_filter( 'pre_get_posts', 'exclude_category_home' );
    
  • Rafael replied

    Unfortunately categories remain..

  •  8,467
    Tahir replied

    @Rafael, Could you provide the page url where i can see the Blog Recent Posts Element ? .

    Be.st 


    ThemeNectar Support Team 

  •  8,467
    Tahir replied

    Hey Again,

    Add this into the Custom CSS box located in your Salient Options panel (All custom css provided is tested in the Live Browser so it will work as intended . If you cant see any changes make sure there is no red cross in the Custom CSS Box as that syntax error would cause all css below it to not show up on the Frontend):

    .nectar-recent-posts-slider_multiple_visible .recent-post-container.container .strong a {
        display: none !important;
    }

    Thanks


    ThemeNectar Support Team 

  • Rafael replied

    Perfect.

    Thanks a lot!