1

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.

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)

Luís P. A.
  • 9,524
  • 2
  • 23
  • 36
  • did you check by `var_dump($posts)` or are you sure there is post which consists the meta post for `sara`. – StreetCoder Feb 25 '15 at 17:00
  • maybe this helps: http://www.advancedcustomfields.com/resources/querying-relationship-fields/ – Ingvi Jónasson Feb 25 '15 at 21:15
  • @Ingvi - i tried with no results...i update my code – Luís P. A. Feb 26 '15 at 10:32
  • Do I understand correctly. You want to create a single page template for persons, that will display the projects that are associated with that person, right? – Ingvi Jónasson Feb 26 '15 at 21:42
  • @Ingvi ... that´s correct... thanks for your help... i already find a solution. I found this link - http://support.advancedcustomfields.com/forums/topic/reverse-query-relationship-subfield-which-is-nested-in-a-repeater-field/ . This link show me the right way (query) – Luís P. A. Feb 27 '15 at 10:56
  • @LuisP.A. Perhaps you can answer your own question? – MastaBaba Jun 22 '16 at 01:46

0 Answers0