Black Friday Sale! Get up to $30 off GP Premium! Learn more ➝

[Resolved] Sticky posts (or specific categories) in footer widget on home page

Home Forums Support [Resolved] Sticky posts (or specific categories) in footer widget on home page

Home Forums Support Sticky posts (or specific categories) in footer widget on home page

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #223241
    Delia

    Hi Tom
    I’ve been browsing through the forum but can’t work out exactly what I need to do. I’m afraid I’m a bit of a newbie!
    One of your replies has the below code for putting specific categories of post on the home page. I’ve activated the Code Snippets plugin and my category name is Company Updates. I’d like to put these categories of posts in my footer widget 4 on my home page which is set to show recent posts. Is there a way to code this? Alternatively is there a post plugin which would work well with the footer widget? Ideally, I’d like to be able to specify post numbers or sticky posts but categories could be a workaround.

    Thank you so much.

    function generate_home_category( $query ) {
    if ( $query->is_home() && $query->is_main_query() ) {
    $query->set( ‘category_name’, ‘home-category-slug’ );
    }
    }
    add_action( ‘pre_get_posts’, ‘generate_home_category’ );

    My version:
    function generate_home_category( $query ) {
    if ( $query->is_home() && $query->is_main_query() ) {
    $query->set( ‘Company Updates’, ‘company-updates’ );
    }
    }
    add_action( ‘pre_get_posts’, ‘generate_home_category’ );

    #223243
    Delia

    Hi Tom, it has just occurred to me that I could just add the links to my key posts (which are our top FAQ questions) in the custom menu of quick links that I have in another footer! Apologies! Would still be interested if there is a way to pull in the recent Company Updates posts automatically, though.

    #223295
    Roberto Enrique

    I think you should definitely try this:
    https://wordpress.org/plugins/recent-posts-widget-extended/
    It does exactly what you need. πŸ™‚

    #223316
    Tom
    Lead Developer
    Lead Developer

    That plugin should work perfectly for you πŸ™‚ Thanks Roberto!

    #223347
    Delia

    Thanks so much both of you – it’s always great to get a recommendation as there are so many plugins out there!

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