Support

Account

Home Forums Front-end Issues Query to display all posts with ACF relationship value Reply To: Query to display all posts with ACF relationship value

  • In case I messed something up, here’s the code I used on my single-company.php to generate the Read More link:

    <?php 
    $company_ID = $post->ID; //get the id of the current company
    $archive = get_post_type_archive_link('post').'?company='.$company_ID;
    ?>

    and here’s the code on my archive.php page:

    <?php get_header(); ?>
    <?php // if is a link to Read More from company single related post
    if(isset($_GET['company'])){ ?>
    	Show all related posts from the company's singular page.
    <?php } else { ?>
    	<?php while ( have_posts() ) : the_post(); // The Loop ?>
                <?php get_template_part( 'content','excerpt' ); ?>
    	<?php endwhile; ?>
    <?php } ?>
    <?php get_footer(); ?>