Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #351178

    Hi,

    On my front home page I would like to display only the sticky posts while leaving the regular blog page intact displaying all posts. On the front page I intent to use a Grid Layout blog with one column.

    Any suggestions?

    BR
    Lars

    #351475

    Hey kihlbaum!

    Try adding this to the bottom of your /enfold/functions.php file.

    add_action( 'parse_query', 'enfold_customization_homepage_sticky_posts' );
    function enfold_customization_homepage_sticky_posts( $query ){
    	if ( is_home() ) {
    		$sticky = get_option( 'sticky_posts' );
    		set_query_var( 'post__in', $sticky );
    	}
    }

    Best regards,
    Elliott

    #351762

    Thanks a lot! However, that code resulted in the opposite: All posts showing on the front page (static page), but only Sticky Posts on my blog page.

    I guess “is_home” returned the blog page instead of the home page.

    #351764

    I might add that the front page has page number 13.

    #351775

    I tried to exchange the boolean to “is_front_page” but that did not work either.

    #352074

    Hi!

    Try creating another separate page for your homepage and use the blog shortcode there as well. Make sure your not using any static pages in Dashboard > Settings > Reading.

    Regards,
    Elliott

    • This reply was modified 10 years ago by Elliott.
    #352300
    This reply has been marked as private.
    #352301

    Addition to previous post:
    Using “is_front_page” results in all posts beeing listedin both the front page AND blog page.
    Using “is_home” results in all posts beeing listed at front page, but only sticky posts beeing shown in the blog page.

    Currently “is_front_page” is used in functions.php.

    #352509

    Hey!

    I was trying to set it back to is_home() but I didn’t see the update button in your editor. You had a static page set in Dashboard > Settings > Reading which I think was causing problems.

    Regards,
    Elliott

    #352574

    I have now changed the functions.php to is_home(). Seems to be the same problem.

    #352766

    Hey!

    Hmm, not sure why that’s not working but let’s make this easier. Instead of using sticky posts create a new category called “featured” or “homepage” and use that with the blog posts shortcode instead. If you do not want to create a category then you can also use post tags.

    Regards,
    Elliott

    • This reply was modified 10 years ago by Elliott.
    #352869

    Thanks for all your efforts! I finally got it to work using the plugin Ultimate Posts Widget.

Viewing 12 posts - 1 through 12 (of 12 total)
  • The topic ‘Blog – only display sticky posts’ is closed to new replies.