WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've got a taxonomy archive to show custom post-types, its got a custom query calling the posts - I can't figure out where to put showposts in it.

global $wp_query; 
    $term = get_term_by( 'slug', get_query_var($wp_query->query_vars['taxonomy']), 

    if (have_posts()) : while (have_posts()) : the_post(); ?> 

In case anyone's wondering I've tried using a new or standard query, but it seems to break some of woocommerce's functionality.

So basically Id like to modify the above query to show all posts...

any ideas? thanks!!

share|improve this question

This code:

$term = get_term_by( 'slug', get_query_var($wp_query->query_vars['taxonomy']), $wp_query->query_vars['taxonomy']); 

... just fetches the term data for the currently queried term, it's not altering the query in any way.

To alter the query for your taxonomy term archives, you want to use the pre_get_posts action. Altering the query in the template just creates a new query, overwriting the original, as the main query for all pages happens before the template is loaded. This code would go in your theme's functions.php or a custom plugin:

function wpa_alter_taxonomy_query( $query ) {
    if ( is_tax( 'your-taxonomy' ) && is_main_query() )
        $query->set( 'posts_per_page', -1 );
add_action( 'pre_get_posts', 'wpa_alter_taxonomy_query' );

just change 'your-taxonomy' to the name of your taxonomy.

share|improve this answer

Your Answer


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.