1、获取页面分类列表
<?php query_posts('showposts=6&cat=54');
//cat=1为调用ID为1的分类下文章
while(have_posts()) : the_post(); ?>
<li>
<a href="<?php echo the_permalink() ?>" title="<?php the_title(); ?>" ><?php the_title(); ?></a>
<?php the_time('Y-m-d'); ?>
</li>
<?php endwhile; ?>
2、文章内容页获取上一条、下一条代码
<div class="shangxia">
<div class="shang"><?php if (get_previous_post()) { previous_post_link('上一条: %link');} else {echo "没有了,已经是最后文章";} ?></div>
<div class="xia"><?php if (get_next_post()) { next_post_link('下一条: %link');} else {echo "没有了,已经是最新文章";} ?></div>
</div>
3、获取Page分类列表
<?php wp_list_pages('title_li=&sort_column=menu_order&child_of=333'); ?>
获取cat分类列表
<?php wp_list_cats("child_of=" . get_query_var("cat") . "&depth=1&hide_empty=0&orderby=order&child_of=59"); ?>
<!--li开始-->
<?php
if(get_category_children(get_query_var("cat")) != ""){
wp_list_cats("child_of=" . get_query_var("cat") . "&depth=1&hide_empty=0&orderby=order");
//获取当前列表分类
}else{
$catID = get_query_var('cat'); // 当前分类ID
$thisCat = get_category($catID);
$parentCat = get_category($thisCat->parent);
// 输出父分类的链接
//echo get_category_link($parentCat->term_id);
$cat = get_category($parentCat->term_id);
echo '<a href="'.get_category_link($parentCat->term_id).'">';
echo $cat->name;
echo '</a>';
}
?>
<!--li结束-->
4、根据分类ID获取标题
<?php
$cat_ID = 72;
//这里是文章的ID
$cat_name = get_cat_name($cat_ID);
echo $cat_name;
//输出文章的 标题
?>
5、当前子页面的栏目名字和链接调用
<?php
if($post->post_parent)
$children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0");
else
$children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0");
if ($children)
{
echo '<ul>';
echo $children;
echo '</ul>';
} ?>
主题测试文章,只做测试使用。发布者:zhaolou,转转请注明出处:https://www.zhaolou.cc/archives/4235