[wp-hackers] list users by (dynamic) meta value

A5D info at a5d.org
Tue Oct 23 09:23:42 UTC 2012


My head hurts.

I'm trying to work out how to list users by dynamic meta value.
The meta value can be anything.

Example:
If I am on page for directors I list the directors, If I'm on the page for actors they get listed.
I can do this by hard coding the meta value in but then I have to manually create a ton of pages - which kind of defeats the whole point.

What I have so far:
<?php
$args = array(
'role' => 'author' ,
'meta_key' => 'team',
'meta_value' => 'Director', <~ THIS NEEDS TO BE DYNAMIC
'order' => 'ASC',
'number' => 25,
);
$authors = get_users($args);
    foreach($authors as $author){
        $author_info = get_userdata($author->ID);
        ?>
        DO THE STUFF
        <?php } ?>

Meta values are added in the users profile.
I suppose i'm missing 2 bits - the dynamic meta value content and where to pull that from - page title perhaps?

I appreciate any direction/ advice/ lumps of code/ slaps for bad coding etc.

TIA

Lee


More information about the wp-hackers mailing list