Site logo

Archived topic

Offset of posts archive ( pre_get_posts )

5 replies · Started by Ben on June 3, 2020

Viewing posts 1–6 of 6

Hi
I have a hook that adds the latest 2 posts before the main list on blog archive (showing them large).

Is there a way to then offset the results below so that these 2 arent listed in the blog archive?

I've tried using pre_get_posts but it was giving strange results when clicking on the "Load more" button .

Can you recommend best way to do this, just on the blog archive, as I have a number of other CPT posts that I dont want effected.

Many thanks
Ben

Hi there,

offsetting the list of posts is a nightmare in WP - as it generally screws up the forward pagination, which also applies to Load More.

Can you share a link to the site so i can take a look if theres an alternative solution?

You can edit your original topic and use the Site URL field to share the link privately.

link added to original topic, many thanks

wow, thats awesome. Initial tests and it seems to work. I'll keep testing but for now it looks good. Many thanks David!

Fingers crossed - hope it works :)

This archived topic is closed to new replies.