如何在wordpress单文章中添加分类(文章) [英] How to add category(posts) in wordpress single post

查看:91
本文介绍了如何在wordpress单文章中添加分类(文章)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿任何人都知道如何添加一个特定类别的帖子在wordpress单post.m给出一个网站的链接,使用它 http://www.animetv.org/anime/one-piece-dub/ 它是一个帖子,包含特定类别的帖子。它被要求为相同的,即与发布thumbnails.Thanks。

Hey any one know how to add a specific category posts in wordpress single post.m giving a link of website that is using it http://www.animetv.org/anime/one-piece-dub/ it is a post that contains posts of a particular category.It is demanded as same i.e. with post thumbnails.Thanks.

推荐答案

只需将此代码放到您的single.php文件中,即可获得您想要的结果:

Just put this code at your single.php file you will get your desired result:

<?php $category = get_the_category(); ?>
<ul>
<?php
$args = array('category' => $category[0]->term_id );
$myposts = get_posts( $args );
foreach ( $myposts as $post ) : setup_postdata( $post ); ?>
    <li>
    <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail();?></a><br/>
        <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
    </li>
<?php endforeach; 
wp_reset_postdata();?>
</ul> 

然后按照您的选择放置css,例如li {float:left;}

And put css for ul li as per your choice like li{float : left;}

这篇关于如何在wordpress单文章中添加分类(文章)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆