你好。当我的帖子被点击时,我想添加一个链接。链接必须转到帖子的类别。我已经走了这么远。但是现在我卡住了。谁能告诉我我该怎么做? thkx
'portriats','posts_per_page'=> 1); ?> <?php $qry = new WP_Query($args ); ?>
<?php if ( $qry->have_posts() ) : ?>
<?php while ( $qry->have_posts() ) : $qry->the_post(); $postcat = get_the_category( $post->ID );?>
<div class="hometile">
<a href="<?php get_category_link( $postcat) ?>"> ==> **I need to get the category of the post. and then let php print the link of the categorey in the href**
<?php the_post_thumbnail(); ?></a>
</div>
<?php endwhile; ?>
<?php endif; ?>
它将显示带有链接的帖子的主要类别
<?php $qry = new WP_Query($args ); ?>
<?php if ( $qry->have_posts() ) : ?>
<?php while ( $qry->have_posts() ) : $qry->the_post(); $postcat = get_the_category();?>
<div class="hometile">
<a href="<?php echo get_category_link( $postcat[0]->term_id ); ?>">
<?php echo $postcat[0]->name; ?>
<?php the_post_thumbnail(); ?>
</a>
</div>
<?php endwhile; ?>
<?php endif; ?>