Community Forums › Forums › Archived Forums › Design Tips and Tricks › Using pre_get_posts to call postID
Tagged: postif, pre_get_posts, sticky
- This topic has 4 replies, 2 voices, and was last updated 12 years, 4 months ago by
Silver007A.
-
AuthorPosts
-
July 22, 2013 at 9:31 am #51836
Silver007A
MemberHi,
I'm using eleven40 theme and have a problem with extra posts appearing on my home page even if I use the featured post plugin, set 7 posts in Setting- Reading and set posts as "sticky" I seem to get my 7 sticky posts plus 3 extras that I don't want to appear.
It's been suggested I use pre_get_posts to call the postID instead of using the sticky option, however, I have to confess I am completely at a loss.
Would someone be good enough to help me with the code to select the 7 posts that I want to appear on my home page please.
Thanks for any help,
🙂
http://www.virtualglobal.co.uk/July 22, 2013 at 10:58 am #51853Brad Dalton
ParticipantYou can modify the number of featured posts in the home.php file
remove_action( 'genesis_loop', 'genesis_do_loop' ); add_action( 'genesis_loop', 'eleven40_grid_loop_helper' ); /** Add support for Genesis Grid Loop */ function eleven40_grid_loop_helper() { if ( function_exists( 'genesis_grid_loop' ) ) { genesis_grid_loop( array( 'features' => 1, 'feature_image_size' => 0, 'feature_image_class' => 'alignleft post-image', 'feature_content_limit' => 0, 'grid_image_size' => 'grid-thumbnail', 'grid_image_class' => 'alignnone', 'grid_content_limit' => 250, 'more' => __( '[Continue reading]', 'genesis' ), ) ); } else { genesis_standard_loop(); } } genesis();
July 22, 2013 at 11:36 am #51863Silver007A
MemberThanks for the help braddalton, but that didn't seem to work. It stripped the columns that eleven40 creates on teh home page, the read more and still showed 3 extra posts that aren't sticky posts.
If anyone can help i would really appreciate it.
Thanks,
🙂
July 22, 2013 at 11:51 am #51864Brad Dalton
ParticipantYou'd need to modify the values in that code so you get 7 features and then make them sticky. You would also need to match your reading settings so only 7 display.
You can't display 7 posts as sticky in a grid unless you modify the code. What you can do is display 7 featured posts as sticky but not in a grid.
Another option is to add styling to your home page posts so they look the same as what they do when they're sticky.
July 23, 2013 at 12:35 pm #52114Silver007A
MemberStudiopress tech supp have advised me this-
If you don't want pagination then I would recommend picking via postID and not using sticky posts. You will have to use the pre_get_posts action to modify the query.
Here is a tutorial on pre_get_posts
http://www.billerickson.net/customize-the-wordpress-query/However, I don't understand the tutorial enough to know where to call the postID.
I don't know php that well I'm afraid.
-
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.