• I just setup my first WP page last night so forgive me if I’m asking for something that either can’t be done or is super easy to work with. I just can’t find it anywhere.

    My site is built more on pages than on posts, so I’m looking to have that “Latest Posts” thing display the 5 latest pages instead. I can’t seem to find a way to do that. I was able to create a block that just lists pages, but that’s not gonna work for me. I’m looking for it to operate just like the Posts block, but with pages instead.

    Thanks in advance for any and all assistance.

    • This topic was modified 2 years, 8 months ago by Jan Dembowski.

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    We can alter any post/page query through the “pre_get_posts” action hook. The trick would be identifying that specific query among all the other queries using the same hook. For example, if it’s the only query asking for 5 posts, that can be used to identify the correct query. You can further check other query vars if that alone is inadequate.
    https://developer.www.ads-software.com/reference/hooks/pre_get_posts/

    Once identified, the “post_type” query var value is changed to “page”. That will get the 5 latest pages for you, but any related output (if any) the block uses to refer to the posts as posts will not change. There are similar ways to change any such strings, but again the tricky part is distinguishing that particular string’s usage from any other usage that shouldn’t be changed.
    https://developer.www.ads-software.com/reference/hooks/gettext/

Viewing 1 replies (of 1 total)
  • The topic ‘Change Latest Posts To Latest Page’ is closed to new replies.