【问题标题】:Wordpress: List categories and list all posts in active categoryWordpress:列出类别并列出活动类别中的所有帖子
【发布时间】:2012-07-24 17:25:49
【问题描述】:

我希望我能在这方面得到一些帮助!我正在尝试在显示类别列表(作为类别本身的链接)的侧栏中实现一些 PHP。如果单击,我当然希望它转到类别页面,然后该类别中的帖子作为链接显示在其下方的列表中。

首页示例: 甲类 B类 C类

A 类主页示例: 甲类 - 发布一 - 发布二 - 后三 B类 C类

如果这是显而易见的事情,我很抱歉。我正在尝试找到自己的解决方案,但到目前为止还没有找到。

再次感谢!

【问题讨论】:

标签: php wordpress


【解决方案1】:

您可以使用此代码显示类别和帖子列表 等级顺序:

<?php
/*
Template Name: Archives with Content
*/
?>
<?php get_header(); ?>
<div id="content" class="widecolumn">
<?php if (have_posts()) : while (have_posts()) : the_post();?>
<div class="post">
<h2 id="post-<?php the_ID(); ?>"><?php the_title();?></h2>
<div class="entrytext">
<?php the_content('<p class="serif">Read the rest of this page &raquo;</p>'); ?>
</div>
</div>
<?php endwhile; endif; ?>
<?php edit_post_link('Edit this entry.', '<p>', '</p>'); ?>
</div>
<div id="main">
<?php //include (TEMPLATEPATH . '/searchform.php'); ?>
<h2>Archives by Month:</h2>
<ul>
<?php wp_get_archives('type=daily&limit=1&show_post_count=1'); ?>

</ul>
<h2>Archives by Subject:</h2>
<ul>

<?php wp_list_categories('orderby=name&show_count=1'); ?>
</ul>
<?php get_footer(); ?>

1.只需将上述代码复制到名为archieve_page.php的文件中即可“归档内容”并点击发布,然后在顶部点击“查看页面”查看页面。

【讨论】:

    【解决方案2】:

    我写了一个小部件,其中包含类似的代码可能会帮助您开始创建小部件:http://wp.leau.co/2010/12/01/sidebar-feed-widget-showing-tweets-stumbles-vids-and-more/

    只需循环上面的类别

    然后用http://codex.wordpress.org/Function_Reference/is_category你可以检查你是否在一个类别页面上,然后用http://codex.wordpress.org/Function_Reference/single_cat_title检查它是否是活动页面

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-07-10
      • 1970-01-01
      • 1970-01-01
      • 2011-12-03
      相关资源
      最近更新 更多