Basically I have 3 Custom Meta checkboxes that I want to be able to filter by let's just use Member 1, Member 2, and Member 3 for these.

The kicker however is that some may use 2,or even all 3 of these.

What I need to be able to do is list all of the pages that have one checked. So a page called 'Member 1' would display anyone with that tag. 'Member 2' would display the same and so on. I've been told that I may be able to accomplish this with wp_list_pages(), but I've had no luck so far.

Also is there a way that I can make my menu dropdowns automatically display these. Like I have a menu labelled Member 1 and when I hover over it, it will show all of the Member 1 checked pages?

Any thoughts?

  • Welcome to WPSE. Lots of thoughts. This site is not an open help forum, however. It's for specific questions that can be answered. Typically, users post code which is failing somehow. wordpress.stackexchange.com/tour
    – jdm2112
    Aug 9 '16 at 20:37

You'll need to test that this works, but I've just been looking at source and I think it will.

wp_list_pages doesn't officially take meta keys or values in its arguments, but it does pass its argument array straight on to get_pages, which does allow you to make a meta query. So, you ought to be able to do this to get pages where the custom field member_2 has the value yes:

echo wp_list_pages( array(
    'meta_key' => 'member_2', 
    'meta_value' => 'yes',
) );

I'd be interested to know if it works!

  • It definitely did. I'll have to style it properly, but that works for the list. Now I just need to duplicate that in my menu, I guess. Aug 10 '16 at 20:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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