-
-
Save billerickson/cbed55d31f697b0d9375ad8ff6b54b94 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Single | |
* | |
* @package EAStarter | |
* @author Bill Erickson | |
* @since 1.0.0 | |
* @license GPL-2.0+ | |
**/ | |
/** | |
* Related Posts | |
* | |
*/ | |
function ea_single_related_posts() { | |
$loop = new WP_Query( array( | |
'posts_per_page' => 3, | |
'post__not_in' => array( get_the_ID() ), | |
'category_name' => ea_first_term( 'category', 'slug' ) | |
) ); | |
if( $loop->have_posts() ): | |
echo '<section class="related-posts">'; | |
echo '<header><h3>Related Posts</h3></header>'; | |
while( $loop->have_posts() ): $loop->the_post(); | |
get_template_part( 'partials/archive', 'related' ); | |
endwhile; | |
echo '</section>'; | |
endif; | |
wp_reset_postdata(); | |
} | |
add_action( 'tha_entry_after', 'ea_single_related_posts', 5 ); | |
// Build the page | |
require get_template_directory() . '/index.php'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment