Go ahead and remove that die() line while we’re thinking about it, so that that doesn’t cause you any issues later. Also, you said when you have content that’s using that ‘relation’ that it outputs correctly, right? Just when there is none is when it spits out everything?
yeah thats correct.
Just for kicks (stabbing in the dark now) what if you move the reset_query outside if the if statement?
wp_reset_query();
May need to wait for someone better at this than me to troubleshoot… I’m stymied as to why wrapping in an if() would kill it.
You could try the other format of if statements without brackets, as are used within that code… but it should accept either.
I appreciate the help=)
Well, another thing while waiting for a solution, do you know why this (also from the loop):
echo '<a href="' . (get_field('extern') ? the_field('extern') : the_permalink()) . '">link</a>';
Outputs this:
"some url here"
<a href></>
The url that should be inside the href=“” is outputed above and outside the a tag?
Is that when you do have posts tagged ‘relation’ ? If not, I’m not sure how it would put out anything at all, yes?
I have to be away for a bit, hopefully you get a resolution before I’m back, but if not I will tackle this again later, it’s kind of annoying me now that I can’t think of an answer , I’m sure it’s something simple we’re overlooking!
Seems like I solved it, wrapping it all in a if statement seemed correct, but when I did it in this way it worked:
<?php
if(get_field('relation')){
$ids = get_field('relation', false, false);
$args = array(
'post_type' => array('posts', 'sidebar-posts'),
'posts_per_page' => 3,
'post__in' => $ids
);
$the_query = new WP_Query( $args );
if ( have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post();
?>
..... rest of the code ....
<?php endwhile; endif; wp_reset_query(); } ?>
Awesome, glad you’ve got it figured out. For some reason it didn’t like the false, false notation I guess?
Anyway, good luck with the rest of it
Yeah seems so=)
Thanks for the help! appreciated!
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.