类别模板帮助

时间:2012-12-19 作者:Kirsty Marks

我在网上找到了一个教程,可以为我在特定类别中存档的帖子创建自定义类别模板。然而,这是针对一个特定的类别ID(见下文),是否有必要创建一个针对所有而不是一个特定ID的模板?

<?php
/*
Template Name: Category-Tutorials
 * The template for displaying Archive pages.
 *
 * Used to display archive-type pages if nothing more specific matches a query.
 * For example, puts together date-based pages if no date.php file exists.
 *
 * Learn more: http://codex.wordpress.org/Template_Hierarchy
 *
 * @package WordPress
 * @subpackage Twenty_Eleven
 * @since Twenty Eleven 1.0
 */

get_header(); ?>

    <section id="primary">
        <div id="content" role="main">

<header class="page-header">
                <h1 class="page-title">
                    <?php if ( is_day() ) : ?>
                        <?php printf( __( \'Daily Archives: %s\', \'twentyeleven\' ), \'<span>\' . get_the_date() . \'</span>\' ); ?>
                    <?php elseif ( is_month() ) : ?>
                        <?php printf( __( \'Monthly Archives: %s\', \'twentyeleven\' ), \'<span>\' . get_the_date( \'F Y\' ) . \'</span>\' ); ?>
                    <?php elseif ( is_year() ) : ?>
                        <?php printf( __( \'Yearly Archives: %s\', \'twentyeleven\' ), \'<span>\' . get_the_date( \'Y\' ) . \'</span>\' ); ?>
                    <?php else : ?>
                        <?php _e( \'Tutorials\', \'twentyeleven\' ); ?>
                    <?php endif; ?>
                </h1>
            </header>

    <ul class="category-7">
        <?php $archive_query = new WP_Query(\'cat=7&showposts=1000\');
        while ($archive_query->have_posts()) : $archive_query->the_post(); ?>
    <li><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></li>
        <?php endwhile; ?>
    </ul>

        </div><!-- #content -->
    </section><!-- #primary -->
我在想也许可以改变以下几点:

<?php $archive_query = new WP_Query(\'cat=7&showposts=1000\');

0 个回复
结束