• Ok, I’m at a complete loss, and I’m fairly sure it’s something straight forward.

    I have a template that contains the following, and the list of people in question are members of different groups. (For instance, students in class X, students in class Y). I’d like to modify the code to be able to filter the returned list of people based on group membership. I’ve been trying to find a simple example of how to do this, but alas, no joy. Can anyone point me in the right direction?

    Thanks much!

    // No direct access
    if ( ! defined( 'ABSPATH' ) ) exit;
    
    // Query events that ended before today
    function people_loop_after_content() {
    
    	return new WP_Query( array(
    		'post_type'			=> 'ctc_person',
    		'paged'				=> ctfw_page_num(), // returns/corrects $paged so pagination works on static front page
    		'orderby'			=> 'menu_order',
    		'order'				=> 'ASC'
    	) );
    
    }
    
    // Make query available via filter
    add_filter( 'loop_after_content_query', 'people_loop_after_content' );
    
    // Load main template to show the page
    locate_template( 'index.php', true );
Viewing 5 replies - 1 through 5 (of 5 total)
  • Moderator bcworkz

    (@bcworkz)

    How is group membership determined? Category? Tag? Taxonomy? Custom field?

    Thread Starter pauhana

    (@pauhana)

    To be honest, all I know is that I created the groups via the normal mechanism (via the WordPress menu, selecting People -> Groups), and then when editing the info for different people, checking the box(es) of the group(s) they are a member of. Is that mechanism considered category, tag, or taxonomy? (Sorry if I’m being dense, but I have no clue…).

    Moderator bcworkz

    (@bcworkz)

    No worries, we’ll get this figured out. The thing is now, there are no People > Groups menu selections in the default WP installation. Either these items are from a theme or plugin, or you have a translated installation and you mis-translated the terminology back to English. Which would be totally understandable, I’m not criticizing your translating skills. There’s no reason for you to know the exact English WP terminology. Could it be Users > Roles you are talking about? Or do you have these in addition to People > Groups?

    If the menu items are from a theme or plugin, you’d need to inquire at the appropriate dedicated support forum to find out how they are assigning people to groups in WP terms.

    Thread Starter pauhana

    (@pauhana)

    Ah, thank you for the help. It is indeed within a theme. Does each theme have a dedicated support forum? I will find the appropriate area to post to. Thanks again, I really appreciate it!

    Moderator bcworkz

    (@bcworkz)

    You’ve probably figured this all out already, but I’ll answer anyway. Each theme in the www.ads-software.com repository has its own support forum. Find your theme after following the “Themes” menu item on any www.ads-software.com page. On the right of your theme’s page is a “View support forum” button that will take you there. Be sure to read any sticky posts there, some authors offer support through their own website. The WP repository templates provide the forum interface whether they are used or not.

    If you purchased your theme, seek support from where ever your purchased it from. Whether you paid for your theme or not, the level of support available can range from nothing or extremely slow to incredibly responsive and helpful. The support provided is an important factor when choosing a theme.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Filtering users via WP_Query’ is closed to new replies.