• Is there a way to exclude pages from the Page List Block? Or a way to limit the list to a particular category?

    • This topic was modified 2 years, 7 months ago by Jan Dembowski. Reason: Moved to Fixing WordPress, this is not an Developing with WordPress topic
Viewing 2 replies - 1 through 2 (of 2 total)
  • @maliwi The Page List Block doesn’t have much for configuration options, but there’s a way you can do this with the ‘Posts List’ block.

    Add the ‘Posts List’ block to your post, change the ‘post type’ to ‘Page’ switch into ‘code editor’ view and you’ll notice an empty parameter in the block data. You can then add the IDs you want to exclude (comma-delimited). See this video for an overview of setting it up:

    https://d.pr/i/4CQ4na

    Moderator bcworkz

    (@bcworkz)

    AFAIK, the block still ultimately uses WP_Query to get the pages, so you could use “pre_get_posts” action to alter the query as desired. The difficulty comes in distinguishing that particular query from all other queries that run through the same action. Perhaps there are some distinct query var values used for this query not used anywhere else to check for in a conditional?

    Or, if the action callback were added from another action that fires just before the block makes its query, and your callback then removes itself from the call stack, any query alterations are less likely to influence other queries.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Exclude pages from Page List Block’ is closed to new replies.