Insert/"sticky" specific post into Loop at specific location
-
I’m having a hard time determining the first direction to take with this. I’m trying to write a plugin that allows users to pick a location for a post to be inserted into the homepage. For example a user can ‘sticky’ an old post to the 2nd location on their front page. My problem is I don’t know how to insert a post into the loop at a specific point. I’m thinking it should be something like the following (but clearly I’m missing the code to insert the post):
add_action ('pre_get_posts', 'add_post_to_frontpage'); function add_post_to_frontpage ($query) { if ( $query->is_home() && $query->is_main_query() && $query->current_position = $positionlocation ) { //insert a given post into this current_position } }
Thanks
- The topic ‘Insert/"sticky" specific post into Loop at specific location’ is closed to new replies.