1

For SEO purposes I use my URLs like this:

site.com/parent/child/

Currently I have pages like this:

site.com/parent/

site.com/page-1/

site.com/page-2/

site.com/page-3/

I want to list some of those page-1, page-2 etc. pages on site.com/parent/ I thought the best way to do this is to add a custom field to those.

So is there a better way to do this? If not, how can I wp list pages based on custom fields?

1 Answer 1

1

Function wp_list_pages() accepts arguments from get_pages() function. To list pages filtered by custom field use meta_key and meta_value in parameters array. A list of accepted parameters can be found here and here.

wp_list_pages([
    'meta_key' => 'your_meta_KEY',
    'meta_value' => 'searched_value', // optional
]);

meta_value is not mandatory, if you skip it, a list of pages with any value of the custom field will be returned.

1
  • I will try it later (i am not at my PC now). TY Commented Apr 25, 2019 at 13:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.