Query posts based on post object – advance custom fields

So i have a custom post type called theprojects which have a repeater field (post_object) base on another custom post type ‘people’ (each post have a person and is details (photo,bio, etc..). Everything it´s ok. In each project i can had one or more person from the custom post ‘people’ using repeater field with a sub field post_object.

Now i want another page call like my projects, that one person is associated to a project and show is projects. The page is done…i´m having trouble with the query/code.

Read More

so imagine this:

project1 -> John, Paul, Sara
project2 -> John, Paul
project3 -> Paul, Sara

Now i want a page that shows the projects individually:

Sara -> project1, project3
Paul -> project1, project2
...

I made this query but did not work

<?php while ( have_posts() ) : the_post(); ?>
    <article>
      <header class="entry-header">
        <h1 class="entry-title">
          <?php the_title(); ?>
        </h1>
      </header>
      <div class="entry-content">
        <?php 

                        $projectos = get_posts(array(
                            'post_type' => 'theprojects',
                            'meta_query' => array(
                                array(
                                    'key' => 'investidores', // name of custom field
                                    'value' => '"' . get_the_ID() . '"', // matches exaclty "441" The investidor id
                                    'compare' => 'LIKE'
                                )
                            )
                        ));

                        ?>
        <?php if( $projectos ): ?>
        <ul>
          <?php foreach( $projectos as $projectos ): ?>
          <li> <a href="<?php echo get_permalink( $projectos->ID ); ?>"> <?php echo get_the_title( $projectos->ID ); ?> </a> </li>
          <?php endforeach; ?>
        </ul>
        <?php endif; ?>
      </div>
    </article>
    <?php endwhile; // end of the loop. ?>

Any ideias? Thanks in advance

Note: Investimento is a repeater field with two (2) sub-fields (investidor(post_object) and investimento(numeric)

Related posts

Leave a Reply