problem when showing wordpress category

Asked

Viewed 64 times

1

I’m developing a theme for Wordpress my menu is generated as follows in header.php

<li><a href="<?php echo get_option('home');?>">Início</a></li>
     <?php wp_list_categories('title_li=&orderby=id'); ?>
     <?php wp_list_pages('title_li=&order=id'); ?>

The problem is that when I access a category when trying to show posts it returns all posts and not those referring to category.

Category.php

<?php if ( have_posts() ) : ?>
  <?php while ( have_posts() ) : the_post(); ?>
    <?php the_title(); ?>
  <?php endwhile; ?>
<?php endif; ?>

2 answers

1

Do it like this:

<?php
   query_posts("category_name=SUA_CATEGORIA");
   while(have_posts()) : the_post();
?>

<h1><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1>
<?php
  endwhile;
  wp_reset_query();
?>
  • the problem is that it’s not just a category!

  • Ever tried using is_category()? Then you pass your category, do an if, don’t know how you want to do it.

  • 1

    Try to give more explanations about your solution, so it will also be useful to future visitors

1


solved the problem was missing the wp_reset_query(); at the end of header.php

Browser other questions tagged

You are not signed in. Login or sign up in order to post.