wp-posts-to-posts
wp-posts-to-posts copied to clipboard
How to show related content for future post
Hi, first, thanky you for this amazing plugin. I have one question, how to show all related posts in single, when is set to shedule. If I Publish the post everything is fine, but if is not published and is set to shedule, related content doesnt show.
This is code I use:
// Find connected pages
$connected = new WP_Query( array(
'connected_type' => 'posts_to_pages',
'connected_items' => get_queried_object(),
'nopaging' => true,
'post_status' => array('publish','future'),
) );
// Display connected pages
if ( $connected->have_posts() ) :
?>
<ul class="submenu">
<?php while ( $connected->have_posts() ) : $connected->the_post(); ?>
<li><a href="<?php the_permalink(); ?>"><?php $post_type = get_post_type_object( get_post_type($post) ); echo $post_type->label ; ?></a> </li>
<?php endwhile; ?>
</ul>
<?php
// Prevent weirdness
wp_reset_postdata();
endif;
Thank you in advance :)
I have the same issue. Obviously "post_status" has no effect.
For those who will land on this topic (like me):
There is a parameter connected_query
to do this :
$connected = new WP_Query( array(
'connected_type' => 'FOO',
'connected_items' => get_queried_object(),
'connected_query' => array(
'post_status' => array('publish','future'),
)
) );