
I’m having issues using a post object field to pull in posts from one post type into the posts from another post type. I’ve actually done this before and it’s worked fine – in fact this is almost identical code to the other site – but for whatever reason on this site it doesn’t work.
Code is below. Couple of notes:
– If you set the meta_value manually to a post ID (eg: ’68’) it outputs the correct posts, but using $post->ID outputs everything from that post type.
– It also doesn’t seem to be outputting any of the custom fields – only general wordpress fields. eg: get_permalink($post->ID) seem to work but get_field(‘short_title’) doesn’t.
<?php
$posts = get_posts(array(
'numberposts' => -1,
'post_type' => 'offer',
'meta_key' => 'bookmaker',
'meta_value' => $post->ID
));
if($posts)
{
echo '<h2>Offers</h2>';
foreach($posts as $post)
{
echo '<div class="reviewoffer"><div class="reviewoffertitle"><a href="' . get_permalink($post->ID) . '">' . get_field('short_title') . '</a></div><div class="reviewoffersummary">' . get_field('summary') . '</div></div>';
}
echo '';
}
?>
<?php wp_reset_postdata(); ?>