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(); ?>
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.