Created
November 16, 2015 08:45
-
-
Save karki-dennis/a6e45c3238d6211d17bc to your computer and use it in GitHub Desktop.
Query post to display its term also
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 | |
$args = array( | |
'post_type' => 'post', | |
); | |
$query = new WP_Query($args); | |
while ($query->have_posts()) : $query->the_post(); | |
?> | |
<div class="news-alert"> | |
<?php $term= wp_get_post_terms($post->ID, 'category', array("fields" => "all")); | |
print_r($term);?> | |
<h3 class="<?php echo $term[0]->slug; ?>"><?php the_title(); | |
?></h3> | |
<?php the_content(); ?> | |
</div> | |
<?php | |
endwhile; | |
wp_reset_query(); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment