最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

The Category page shows all the posts, without differentiating by categories

programmeradmin1浏览0评论

I'm using a custom template, and when a category is selected in a blog post, it takes you to the Category page where the articles related to that category are displayed, however all posts are currently being displayed. This is the code of my Category.php

<main role="main">
    <!-- section -->
    <section>

        <h1><?php _e( 'Articles for category ', 'html5blank' ); single_cat_title(); ?></h1>

        <?php get_template_part('loop'); ?>
        

        <?php get_template_part('pagination'); ?>

    </section>
    <!-- /section -->
</main>

I guess the issue is in the Loop:

Do I have to modify the Loop.php then? And if the loop is being used also in tag.php, how can I modify it, without affecting the other page?

This is the code in the loop.php:

<!-- article -->
<article id="post- <?php the_ID(); ?>" <?php post_class(); ?>>

</article>


    <!-- post thumbnail -->

    <?php if ( has_post_thumbnail()) : // Check if thumbnail exists ?>
        <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
            <?php the_post_thumbnail(array(110,110)); // Declare pixel size you need inside the array ?>
        </a>
    <?php endif; ?>
    <!-- /post thumbnail -->

    <!-- post title -->
    <h2 color="#ffffff">
        <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a>
        </h2>
    <!-- /post title -->

    <!-- post details -->
    <span class="date"><?php the_time('F j, Y'); ?> <?php the_time('g:i a'); ?></span>
    <span class="author"><?php _e( 'Published by', 'html5blank' ); ?> <?php the_author_posts_link(); ?></span>
    <span class="comments"><?php if (comments_open( get_the_ID() ) ) comments_popup_link( __( 'Leave your thoughts', 'html5blank' ), __( '1 Comment', 'html5blank' ), __( '% Comments', 'html5blank' )); ?></span>
    <!-- /post details -->

    <?php html5wp_excerpt('html5wp_index'); // Build your custom callback length in functions.php ?>

    <?php edit_post_link(); ?>

</article>
<!-- /article -->
<!-- article -->
<article>
    <h2><?php _e( 'Sorry, nothing to display.', 'html5blank' ); ?></h2>
</article>
<!-- /article -->

Any help will be more than welcome!

发布评论

评论列表(0)

  1. 暂无评论