-
AuthorPosts
-
November 14, 2014 at 10:11 am #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
LarsNovember 14, 2014 at 8:00 pm #351475Hey 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,
ElliottNovember 15, 2014 at 10:05 am #351762Thanks 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.
November 15, 2014 at 10:06 am #351764I might add that the front page has page number 13.
November 15, 2014 at 11:17 am #351775I tried to exchange the boolean to “is_front_page” but that did not work either.
November 16, 2014 at 5:43 pm #352074Hi!
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.
November 17, 2014 at 9:56 am #352300This reply has been marked as private.November 17, 2014 at 10:02 am #352301Addition 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.
November 17, 2014 at 4:37 pm #352509Hey!
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,
ElliottNovember 17, 2014 at 5:46 pm #352574I have now changed the functions.php to is_home(). Seems to be the same problem.
November 18, 2014 at 12:20 am #352766Hey!
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.
November 18, 2014 at 10:27 am #352869Thanks for all your efforts! I finally got it to work using the plugin Ultimate Posts Widget.
-
AuthorPosts
- The topic ‘Blog – only display sticky posts’ is closed to new replies.