Last active
April 15, 2020 11:09
-
-
Save vanaf1979/df67acc72406a26726b03404835c44a2 to your computer and use it in GitHub Desktop.
WordPress: Related posts with WP_Query. https://since1979.dev/wordpress-related-posts-with-wp_query/
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 | |
$related_query = new WP_Query(array( | |
'post_type' => 'post', | |
'category__in' => wp_get_post_categories(get_the_ID()), | |
'post__not_in' => array(get_the_ID()), | |
'posts_per_page' => 3, | |
'orderby' => 'date', | |
)); | |
?> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment