WordPress.org

Forums

post under a category are not displaying correctly (1 post)

  1. jothimoorthy.s
    Member
    Posted 1 year ago #

    This is my category.php

    <?php Starkers_Utilities::get_template_parts( array( 'parts/shared/html-header', 'parts/shared/header' ) ); ?>

    <div class="wrap main">

    <?php if ( have_posts() ): ?>
    <?php
    $category = get_the_category();
    ?>

    <div class="content">

    <div id="home_posts">

    <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    query_posts($query_string . '&posts_per_page=2&offset=1&paged='.$paged);
    $i = 0; ?>

    <h2 class="cat_name <?php echo $category[0]->cat_name; ?>"><?php echo single_cat_title( '', false ); ?></h2>

    <?php while ( have_posts() ) : the_post(); ?>
    <?php
    $i++; ?>
    <!---<article class="home_post item <?php echo $category[0]->cat_name; ?>" >

    <div class="icon">
    </div>

    <div class="featured_image">
    <?php the_post_thumbnail('normal-home'); ?>
    </div>

    <div class="home_content">
    <h3>" title="Permalink to <?php the_title(); ?>" rel="bookmark"><?php the_title(); ?></h3>

    <div class="excerpt"><?php the_excerpt(); ?>
    ">Read More</div>

    <div class="home_meta"><time pubdate><?php the_time('M d, Y') ?></time> <span class="padding20">/</span>
    <span>Share</span><span class="padding20">/</span>
    <span class="home_comments"><?php comments_popup_link('0 Comments', '1 Comment', '% Comments'); ?></span>
    </div>

    </div>

    </article> --->
    <article class="home_post item <?php echo $category[0]->cat_name; ?> row<?php if ($i % 2 == 0) { echo "2"; } ?>">

    <div class="icon">
    </div>

    <div class="featured_image">
    "><?php the_post_thumbnail('normal-home'); ?>
    </div>

    <div class="home_content">
    <h3>" title="Permalink to <?php the_title(); ?>" rel="bookmark"><?php the_title(); ?></h3>

    <div class="excerpt"><?php the_field('rich_excerpt'); ?>
    ">Read More</div>

    <div class="home_meta"><time pubdate><?php the_time('M d, Y') ?></time> <span class="padding20">/</span>
    <span>Share</span><span class="padding20">/</span>
    <span class="home_comments"><?php comments_popup_link('0 Comments', '1 Comment', '% Comments'); ?></span>
    </div>

    </div>

    </article>

    <?php endwhile; ?>

    <!-- Paging Start -->
    <div class="paging">

      <?PHP
      global $wp_query;
      $big = 999999999; // need an unlikely integer
      $args = array(
      'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
      'format' => '?page=%#%',
      'total' => $wp_query->max_num_pages,
      'current' => max( 1, get_query_var( 'paged') ),
      'show_all' => false,
      'end_size' => 3,
      'mid_size' => 2,
      'prev_next' => True,
      'prev_text' => __('Previous'),
      'next_text' => __('Next'),
      'type' => 'list',
      );
      echo paginate_links($args);
      ?>

    </div>
    <!-- // Paging End -->

    <?php else: ?>
    <h2>No posts to display in <?php echo single_cat_title( '', false ); ?></h2>
    <?php endif; ?>

    </div>

    </div>

    <?php Starkers_Utilities::get_template_parts( array( 'parts/shared/footer','parts/shared/html-footer' ) ); ?>

    If I have a category named features It does not fetch me the correct posts under it. The code may be wrong.I am not very technically strong.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags