1
Hello, good morning.
Guys, I’m having trouble sorting posts in the wordpress categories.
Ex: I have the category news, movies, music, images.. I want to sort the posts of these categories in ascending order. I used the following code
<?php query_posts("order=ASC"); ?>
But instead of just showing posts tied to the category, it pulls all posts from the site.
I also used
$args = array('post_type'=>'post','orderby'=> 'title', 'order' => 'ASC');
The same problem occurred, instead of listing the category posts in ascending order, it lists all posts.
The complete code of category.php
that’s the one:
<?php if ( have_posts() ) : ?>
<header class="container">
<?php
the_archive_title( '<h1 class="text-center">', '</h1>' );
the_archive_description( '<h4 class="text-center">', '</h4>' );
?>
</header><!-- .page-header -->
<section class="categorias">
<div class="container">
<?php while ( have_posts() ) : the_post();?>
<?php if (get_post_meta($post->ID, 'reservado', true) == 'no'): ?>
<div class="col-md-4">
<h3>
<a href="<?php echo get_permalink();?>">
<?php the_title();?>
</a>
</h3>
<?php echo odin_thumbnail(400, 200, true, 'minha-classe' ); ?>
</div>
<?php endif ?>
<?php endwhile; ?>
<div class="col-md-12">
<div class="text-center">
<ul class="pagination">
<li><?php echo paginate_links(); ?></li>
</ul>
</div>
</div>
<?php else:?>
<div class="col-md-12 text-center">
<h1>Não existem pontos nesta semana</h1>
<img src="/logo.png" class="img-responsive">
<?php get_search_form(); ?>
</div>
<?php endif; ?>
</div>
</section>
Thanks for your attention!
Leo, do you want to order rising by date or post title?
– Giovanni Bernini
Hello, Giovanni. Need to align with the title, and list only posts in the category linked to the post, and not random.
– Leonardo