Issue grabbing post connected to future post
On my home template I’m grabbing the most recent published post of a custom post type called “tsa_announcement”.
Just below this I’m querying the most recent “future” post of the same custom post type “tsa_announcement” … but, only because I have connected a news “post” to the future “tsa_announcement” and would like to show that connected news post’s title and permalink.
Currently I am attempting to do this with the following code as my second new WP_Query on the template … the first query has been closed out with wp_reset_query~
<?php global $post; $my_query = null; $my_query = new WP_Query( array( 'post_type' => 'tsa_announcement', 'post_status' => 'future', 'tsa_announcement_type' => 'exhibition-opening' )); ?> <?php while ($my_query->have_posts()) : $my_query->the_post();?> <?php // Find connected pages (for all posts) p2p_type( 'news_and_announcements' )->each_connected( $my_query ); ?> <?php // Display connected pages p2p_list_posts( $post->connected, 'before_list=&after_list=&before_item= &after_item=' ); ?> <?php endwhile; ?> <?php wp_reset_query(); ?>
… but, I am receiving SQL errors …
should this even work with a future post?
Thanks as always Scribu!
- The topic ‘Issue grabbing post connected to future post’ is closed to new replies.