Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

My default wordpress set hold 10 posts per page.

In category.php , I want to override this with 999 post per page, the problem is that isn't working at all.

When I use the following code. it doesn't adjust alphabetically or shows 999 posts

    <?php get_header(); ?>

<section id="index" class="index">
  <div class="wrap">

    <div class="filter">

      <dl id="filters" class="dropdown drop-model">
        <dt><a href="#"><span>Selecciona el modelo de tu auto</span><small>&#9662;
        </small></a></dt>
        <dd>
          <ul>
            <li><a href="" data-filter="*">Todos</a></li>
            <li><ul class="thead-inside"><li>Modelo</li><li>Version</li><li>Año</li></ul></li>
            <?php
            global $query_string;

            $args = array(
              'post_per_archive_page' => '999' ,
              'orderby' => 'name',
              'order' => 'ASC'
              );

              $the_query = new WP_Query($query_string,$args); ?>

              <?php
              if ( $the_query->have_posts() ) :
                while ( $the_query->have_posts() ) : $the_query->the_post();
              ?>
              <li><a href="#" data-filter=".<?php theSlug(); ?>-<?php getYearTire(); ?>">
                <ul class="tr-inside">
                  <li><?php the_title(); ?></li>
                  <li><?php the_version(); ?></li>
                  <li><?php getYearTire(); ?></li></ul>
                </a>
              </li>
            <?php endwhile; endif; ?>
            <?php wp_reset_postdata(); ?>

          </ul>
        </dd>
      </dl>
  </div>

  <article class="clearfix">
   <ul class="getTire thead">
    <li>Auto</li>
    <li>Modelo</li>
    <li>Version</li>
    <li>A&ntilde;o</li>
    <li>Medida</li>
    <!-- <li>Tipo</li> -->
    <li></li>
  </ul>
</article>

<div class="events" id="events">
  <?php
  global $query_string;

  $args = array(
    'post_per_archive_page' => '999' ,
    'orderby' => 'name',
    'order' => 'ASC'
    );

    $the_query = new WP_Query($query_string,$args); ?>
    <?php
    if ( $the_query->have_posts() ) :
      while ( $the_query->have_posts() ) : $the_query->the_post();
    ?>

    <article class="<?php theSlug(); ?>-<?php getYearTire(); ?> <?php the_version(); ?> <?php the_options(); ?> clearfix">
      <figure><?php the_post_thumbnail(); ?></figure>
      <ul class="getTire">
        <li><?php the_category(', '); ?></li>
        <li><?php the_title(); ?></li>
        <li><?php the_version(); ?></li>
        <li><?php getYearTire(); ?></li>
        <li><?php whohaveit(); ?></li>
        <!--  <li><?php// the_type(); ?></li> -->
        <li><input class="btn" value="Busca" onclick="window.location='/tienda/product-tag/<?php simple_tag(); ?>'"></li>
      </ul>
    </article>


  <?php endwhile; endif; ?>
</div>


<?php wp_reset_postdata(); ?>




</div>
</section>
<div class="hidden" id="slider"></div>
<?php get_footer(); ?>

Thanks

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

The issue with your query is that new WP_Query($query_string,$args); is not correct syntax, however, creating a new WP_Query is not the way to do what you want. See the codex page for pre_get_posts for the correct way to modify the main query.

I assume by setting posts per page to 999, you want to show all posts, so just use -1 instead to remove the limit from the query. This would go in your theme's functions.php file:

function wpa90381_category_query( $query ) {
    if ( $query->is_category() && $query->is_main_query() ) {
        $query->set( 'posts_per_page', -1 );
        $query->set( 'orderby', 'name' );
    }
}
add_action( 'pre_get_posts', 'wpa90381_category_query' );
share|improve this answer
    
Hey @Milo thanks again.... it worked like charm... now i have to make look this better, 'cos with all post showing it looks awful. http://tirego.mx/category/audi –  Locke Mar 11 '13 at 18:58
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.