• Resolved Marcelo Herrera

    (@rafadizeo)


    Hello

    I have a problem to show all post from current category. This is the code I’m using (in category.php) which shows me all post category except the last (most recent post). This means that if for a category have associated post 10, shows me 9 oldest but not the last (most recent).

    <div class="listadocat">
    		<h3>Capítulos de <?php echo single_cat_title("", false); ?> Online</h3>
    		<ul id="simple">
    		<?php
    		global $post;
    		$category = get_the_category($post->ID);
    		$category = $category[0]->cat_ID;
    		$myposts = get_posts(array('numberposts' => -1, 'offset' => 5, 'category__in' => array($category), 'post__not_in' => array($post->ID),'post_status'=>'publish'));
    		foreach($myposts as $post) :
    		setup_postdata($post);
    		?>
    			<li>
    			<a href="<?php the_permalink(); ?>">
    			<?php the_title(); ?></a>
    			</li>
    		<?php endforeach; ?>
    		<?php wp_reset_query(); ?>
    		</ul>
    	</div>

    I hope someone can help me, ty.

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Problem showing latest post from current category’ is closed to new replies.