The current post that is being displayed is the child post (a story written by an author). My goal is to display below the story a formatted "author box" that contains fields from the parent custom post (the parent of the story, which is the author of the story).
Would a View work better than a Content Template for displaying the parent of the current post? There will not be multiple parent posts associated with the current post (so if Views are best for displaying lists, I don't need that).
Here's my home.php template code (minus some of the theme's layout stuff):
<?php // THIS PART gets the current day's post only
date_default_timezone_set('America/Los_Angeles');
$today = getdate();
$args_today = array(
'date_query' => array(
array(
'year' => $today['year'],
'month' => $today['mon'],
'day' => $today['mday'],
),
),
'posts_per_page' => '1'
);
$query_today = new WP_Query( $args_today );
// NEXT PART is for assigning the placeholder page if there isn't a post scheduled for today
$args_pageid = array(
'page_id' => '287',
);
$query_pageid = new WP_Query( $args_pageid );
?>
<?php // NEXT we create our custom query
if ( $query_today->have_posts() ) {
$custom_query = $query_today;
} else {
$custom_query = $query_pageid;
} ?>
<?php // HERE WE DISPLAY the content of today's post, or the placeholder if one isn't scheduled for today
while( $custom_query->have_posts() ) : $custom_query->the_post(); ?>
<article id="post-<?php the_ID(); ?>" <?php post_class('gridlove-box box-vm'); ?>>
<?php get_template_part('template-parts/home/content-'.$layout['content']); ?>
</article>
>>>>> THIS IS WHERE I TRIED TO RENDER THE VIEW TEMPLATE
<?php endwhile; ?>
I'm just looking at the syntax of the documentation page example and am not sure how to specify "the current post" when I don't know exactly which post ID it will be.
Their example: <?php echo render_view_template( 80 , $mypost ); ?>
Is an argument required there, or should it default to the current post if it's in a loop like this? Now that you can see my code, what variable (or PHP code) could I place there for the current post?
<?php the_ID(); ?> does return the correct story/child post ID, the current one in the loop. Is there a way to put _that_ as an argument inside the render shortcode?