Created
December 8, 2014 22:38
-
-
Save j0lvera/d5aa7d2db9ca8481cd3b to your computer and use it in GitHub Desktop.
How to print categories in a post, WordPress
This file contains hidden or 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 | |
$categories = get_the_category( $post-> ID ); | |
$category = $categories[0]->cat_name; | |
// How to use it | |
$args = array( | |
'post_type' => 'post-type-name', | |
'category_name' => $category | |
); | |
$query = new WP_Query( $args ); | |
while ( $query->have_posts() ): $query->the_post; | |
the_permalink(); | |
endwhile; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment