如何创建WordPress自定义类别页面

时间:2016-04-13 10:15:19

标签: wordpress

我想创建一个类别页面,显示类别名称,描述和缩略图。当我们点击应在下一页显示其帖子的任何类别时,每个类别都应链接到其帖子。

<?php get_header(); ?>

<div class="container-wrap">

    <div class="container main-content">

    <div class="container">

                <h1 class="page-header">
                <?php echo category_description(); ?>
                </h1>

        <div class="row">

            <div class="col-md-4 portfolio-item">
                <a href="#project-link">
                    <img src="<?php bloginfo('template_url'); ?>/img/700x400.png" alt="<?php echo get_the_title(); ?>" title="<?php echo get_the_title(); ?>" width="250" height="180" />
                </a>
                <h3>
                <a href="<?php echo get_category_link( $category_id=65 ) ?>">
                <?php echo get_cat_name(65);?>
                </a>
                </h3>
                <p><?php  echo category_description(); ?></p>
            </div>

            <div class="col-md-4 portfolio-item">
                <a href="#project-link">
                    <img src="<?php bloginfo('template_url'); ?>/img/700x400.png" alt="<?php echo get_the_title(); ?>" title="<?php echo get_the_title(); ?>" width="250" height="180" />
                </a>
                <h3>
                <a href="<?php the_permalink() ?>">
                <?php echo get_cat_name(68);?>
                </a>
                </h3>
                <p><?php  echo category_description(); ?></p>
            </div>

            <div class="col-md-4 portfolio-item">
                <a href="#project-link">
                    <img src="<?php bloginfo('template_url'); ?>/img/700x400.png" alt="<?php echo get_the_title(); ?>" title="<?php echo get_the_title(); ?>" width="250" height="180" />
                </a>
                <h3>
                <a href="<?php the_permalink() ?>">
                <?php echo get_cat_name(70);?>
                </a>
                </h3>
                <p><?php  echo category_description(); ?></p>
            </div>



            </div>

        <div class="row">

            <div class="col-md-4 portfolio-item">
                <a href="#project-link">
                    <img src="<?php bloginfo('template_url'); ?>/img/700x400.png" alt="<?php echo get_the_title(); ?>" title="<?php echo get_the_title(); ?>" width="250" height="180" />
                </a>
                <h3>
                <a href="<?php the_permalink() ?>">
                <?php echo get_cat_name(67);?>
                </a>
                </h3>
                <p><?php  echo category_description(); ?></p>
            </div>

            <div class="col-md-4 portfolio-item">
                <a href="#project-link">
                    <img src="<?php bloginfo('template_url'); ?>/img/700x400.png" alt="<?php echo get_the_title(); ?>" title="<?php echo get_the_title(); ?>" width="250" height="180" />
                </a>
                <h3>
                <a href="<?php the_permalink() ?>">
                <?php echo get_cat_name(71);?>
                </a>
                </h3>
                <p><?php  echo category_description(); ?></p>
            </div>

            <div class="col-md-4 portfolio-item">
                <a href="#project-link">
                    <img src="<?php bloginfo('template_url'); ?>/img/700x400.png" alt="<?php echo get_the_title(); ?>" title="<?php echo get_the_title(); ?>" width="250" height="180" />
                </a>
                <h3>
                <a href="<?php the_permalink() ?>">
                <?php echo get_cat_name(72);?>
                </a>
                </h3>
                <p><?php  echo category_description(); ?></p>
            </div>



            </div>

        <div class="row">

            <div class="col-md-4 portfolio-item">
                <a href="#project-link">
                    <img src="<?php bloginfo('template_url'); ?>/img/700x400.png" alt="<?php echo get_the_title(); ?>" title="<?php echo get_the_title(); ?>" width="250" height="180" />
                </a>
                <h3>
                <a href="<?php the_permalink() ?>">
                <?php echo get_cat_name(69);?>
                </a>
                </h3>
                <p><?php  echo category_description(); ?></p>
            </div>

            <div class="col-md-4 portfolio-item">
                <a href="#project-link">
                    <img src="<?php bloginfo('template_url'); ?>/img/700x400.png" alt="<?php echo get_the_title(); ?>" title="<?php echo get_the_title(); ?>" width="250" height="180" />
                </a>
                <h3>
                <a href="<?php the_permalink() ?>">
                <?php echo get_cat_name(74);?>
                </a>
                </h3>
                <p><?php  echo category_description(); ?></p>
            </div>
+   
            </div>

    </div>

    </div>
    </div>

<?php get_footer(); ?>

1 个答案:

答案 0 :(得分:0)

对于自定义类别页面,您必须在主题根目录中创建一个名为taxonomy-category-slug-here.php的PHP文件。它会对你有用。

taxonomy-category-slug-here.php