Home › Forums › General Issues › Display meta_value based on URL
Hi there,
ok, so I have a post that I’ve build which allows a CSV to be uploaded and parsed into an HTML table, plus a few other bits of information. ACF does a great job here. This would be a ‘draw’ for a race. Now sometime later I repeat the process for the ‘results’ page – it has extra information like a race report, plus the actual HTML table of results. There is required field to go back to the ‘draw’ post as well.
Now, on the original ‘draw’ post it would be great to have a link to the ‘results’ post and done automatically.I’m pretty certain this can be done as the ‘results’ page stores the link back to the ‘drafts’ page.
So far I’ve come up with this:
<?php
$resultLink = get_permalink( $post->ID );
$posts = get_posts(array(
'numberposts' => -1,
'post_type' => 'post',
'meta_key' => 'draw_link',
'meta_value' =>
));
?>
<?php foreach( $posts as $post ):
setup_postdata( $post )
?>
Output the link</P>
<?php endforeach; ?>
<?php wp_reset_postdata(); ?>
Somehow I’m hoping that I can get the post to say, ‘hey the meta_value for draw_link is the same as my URL’ so it will then show a link to the post which first has the meta_key/meta_value pair.
So any help would be great. Does all that make sense?
Chris
Hi John,
it would be a Page Link to a post. Thanks for taking the time to look at my request.
regards, Chris
after some digging it appears my first question didn’t matter, the page link field stores the post ID, but there will be a problem if something other than a post is selected, not sure what is stored for those.
$resultLink = get_permalink( $post->ID );
$posts = get_posts(array(
'numberposts' => -1,
'post_type' => 'post',
'meta_key' => 'draw_link',
'meta_value' => $post->ID
));
The topic ‘Display meta_value based on URL’ is closed to new replies.
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.