如何按类别和日期组织帖子

时间:2014-01-16 作者:user45268

我会尽量说清楚的。

我正在做一个项目,需要按类别和日期组织帖子。我需要这样的东西:

第一步:年度档案清单

2014年:1月-2月-3月-4月-5月-6月-7月-8月-9月-10月-11月-2013年12月-2011年-2010年。。。

第二步:单击年份链接,您将被引导到另一个页面,其中列出了相关月份的类别和子类别。

音乐(2014年1月)摇滚“交流/直流”嘻哈音乐的历史“Bell Biv Devoe发生了什么事?”流行音乐布鲁斯·斯普林斯汀(BruceSpringsteen)——法雷尔·威廉姆斯(PharrellWilliams)寄予厚望的其他大卫·鲍伊(DavidBowie)的《第二天》(The Second Day U2)

子类别可以每月使用,也可以创建新类别并仅使用一次。主要类别(音乐)将没有帖子。

我可以(第二步)使用此页面上的代码从类别和子类别发布工作http://www.cssreflex.com/snippets/list-wordpress-posts-category/但它不限于特定的月份或年份。

感谢您帮助我或帮助我找到解决问题的正确方向。

1 个回复
SO网友:user45268

为了寻找解决方案,我想提供更多有关我迄今为止所做工作的信息:

我的实际配置-WordPress:3.8-PHP:5.3-主题:基于s(下划线)的自定义-Hebergour:local XAMPP

我的存档模板

        <main id="main" class="site-main" role="main">

        <?php
        // get all the categories from the database
        $cats = get_categories(\'child_of=34\'); //cat 34 is the main category

            // loop through the categries
            foreach ($cats as $cat) {
                // setup the cateogory ID
                $cat_id= $cat->term_id;
                // Make a header for the cateogry
                echo "<h2>".$cat->name."</h2>";
                // create a custom wordpress query
                query_posts("cat=$cat_id&posts_per_page=-1");
                // start the wordpress loop!
                if (have_posts()) : while (have_posts()) : the_post(); ?>

                    <?php // create our link now that the post is setup ?>
                    <a href="<?php the_permalink();?>"><?php the_title(); ?></a>
                    <?php echo \'<hr/>\'; ?>

                <?php endwhile; endif; // our wp loop will start again for each category ?>
            <?php } // done the foreach statement ?>

    </main><!-- #main -->
1-尝试使用wp\\u get\\u归档,我有个月的列表,但不可能排除/包括特定类别。

2-尝试使用wp\\u list\\u categories,我得到了categories列表,但无法排除/包括特定类别。

我找到了“WordPress分类档案”插件,但他自2011年以来一直没有更新过我也找到了http://kwebble.com “WordPress插件类别存档”,但不再维护。

仍在寻找解决方案。

谢谢你的帮助

结束