- This topic has 3 replies, 3 voices, and was last updated 3 years, 4 months ago by
David.
-
AuthorPosts
-
November 17, 2022 at 3:50 am #2419347
mooore
…AND prevent duplicate post there, EVEN though the post have multiple categories each.
So I’ve installed this Dispatch style and went from there, but would like to build the homepage as follows:
* the post grid that came with the style, displaying latest post
* headline + 4-6 latest posts from certain category
* headline + 4-6 latest posts from certain category
AND prevent those from duplicating?
I’ve searched quite a bit on this topic and really didn’t find any great solution.
Am I supposed to build things with WP shop posts? or use the generate press loops? etc.
Not sure what is the best way?
Been playing with the query loops etc. but my time is limited and I just need to get the structure up and display correctly before getting ahead with loads of content (in case I need to revert back to only 1 category per post)
would greatly appreciate some help on this =)
November 17, 2022 at 11:09 am #2420218Ying
StaffCustomer SupportAm I supposed to build things with WP shop posts? or use the generate press loops? etc.
Do not use WP show posts as we’ve stopped updating or supporting it. We would recommend using the Query loop block of GenerateBlocks plugin.
November 18, 2022 at 1:47 am #2421039mooore
ok, and what about preventing the duplicate posts?
November 18, 2022 at 6:25 am #2421392David
StaffCustomer SupportHi there,
excluding the latest posts from over query loops:
1. Add this PHP Snippet to your site:
add_filter( 'generateblocks_query_loop_args', function( $query_args, $attributes ) { $args = array( 'post_type' => 'post', 'posts_per_page' => 5, ); $latest_posts = new WP_Query($args); $latest_post_ids = wp_list_pluck($latest_posts->posts, 'ID'); if ( ! empty( $attributes['className'] ) && strpos( $attributes['className'], 'remove-latest-posts' ) !== false ) { // Merge the current $query_args which contains arguments defined in the editor with your ordering arguments return array_merge( $query_args, array( 'post__not_in' => $latest_post_ids, ) ); } return $query_args; }, 10, 2 );Adjust the
'posts_per_page' => 5,value to match the number of latest posts you’re displaying.2. Any other Query Loops you want to remove those duplicate posts from you by:
2.1 Edit the Query Loop block, and inside that select its Grid Block.
2.2 In Advanced > Additional CSS Class(es) add:remove-latest-postsIn regards to posts in multiple categories, de-duping them isn’t really possible without some other data, how do we determine which pots are displayed and which are not?
-
AuthorPosts
- You must be logged in to reply to this topic.