• guillermovargasquisoboni

    (@guillermovargasquisoboni)


    Hello,

    I am discovering this plugin and I am advancing really fast with its implementation, but I am having some troubles for creating a list of people in a personal project.

    In this project, I am playing with three different custom post types, that is: people, events and books. I created three principal relationships between them : author (relationship between people and book), organiser (a first relationship between people and event) and participant (a second relationship between people and event). That means that my relationships are also defining some people’s roles.

    I need help to create a list of people in which I can separate them by roles. In this way :

    – A List of authors : people connected with books.
    – A List of organisers: people connected with events (1).
    – A List of participants: people connected with events (2).

    The list will be printed in a specific template called ??list-of-people.php??. By the moment, I have managed to create a list of people, but I have been unable to separate them according to the roles or relationships that I created in a specific plugin related to MB Relationships. I managed to print and separate the relationships created when I am working on a single event template or on a single person template. In this case, I cannot figure out what kind of query can I use on my “list-of-people.php” template to filter people following the relationships created before. Can you put me on the good way?

Viewing 1 replies (of 1 total)
  • hello,

    in your CPT people, you save the role in a post_meta ?

    you can filter in the wp_query like this :

    $args = array(
    	'post_type' => 'people', // your custom post type
    	'meta_key' => 'the_role', // the key of post_meta
    	'meta_value' => 'authors', // for exemple
    	'meta_compare' => '=',
            'relationship' => array( // YOUR RELATIONSHIP INFORMATION
                'id'   => 'posts_to_pages',
                'from' => get_the_ID(), // You can pass object ID or full object
            ),
            'nopaging'     => true,
    );
    $query = new WP_Query( $args );

    I hope this helps.

Viewing 1 replies (of 1 total)
  • The topic ‘Display a list with different relationships’ is closed to new replies.