• Resolved maijx

    (@maijx)


    Hi,
    There are two relationship fields in my post, one of theme is for selecting the author and the other one is for selecting a book.
    When i do reverse query everything goes fine and ALM works fine. but when it comes to author relationship field it queries current post title and permalink instead of author.
    this is the code that i use in repeater template:

    
    <?php
    $selectAuthor = get_field('author_book_relation');
    if( $selectAuthor ){ ?>
    <?php foreach( $selectAuthor as $p): ?>
     <?php esc_html_e( 'Analysist: ', 'pastishow' ); ?>
     <a href="<?php echo get_permalink( $p->ID ); ?>">
      <?php echo get_the_title( $p->ID ); ?>
    </a>
    <?php endforeach; ?>
     <?php } ?>

    How can i fix this issue so that ALM query the relationship inside repeater template?

    • This topic was modified 7 years, 9 months ago by maijx.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Darren Cooney

    (@dcooney)

    Hi @maijx,
    Can you try adding global $post; at the top of your repeater and then pass $post->ID into your get_field() functions.

    <?php
    global $post;
    $selectAuthor = get_field('author_book_relation', $post->ID);
    ...
    ?>

    Let me know how you make out.

    Cheers,

    • This reply was modified 7 years, 9 months ago by Darren Cooney.
    Thread Starter maijx

    (@maijx)

    I used WP_QUERY and now it’s fixed

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Problem with relationships’ is closed to new replies.