Support » Fixing WordPress » wp_query outputting my posts twice

  • Resolved thomas



    I’m customizing the taxonomy.php template to have the posts displayed in alphabetical order. it’s working but I can’t figure why the posts are outputted twice… even if I use reset_post_data…
    here is my code :

    $query = new WP_Query(array(
    	'post_type' => 'reference',
    	'orderby' => 'title',
    	'order' => 'ASC'
    if($query->have_posts()) : while($query->have_posts()) : $query->the_post();
    					<div class="vignette-cata">
    							<a href="<?php the_permalink() ?>"><?php the_post_thumbnail('full'); ?></a>
    							<figcaption><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></figcaption>
    <?php endwhile; endif; wp_reset_postdata(); ?>

    have I done something wrong ?…

Viewing 3 replies - 1 through 3 (of 3 total)
  • Michael


    Forum Moderator

    what is the context of that code?

    please post the full code of the template.

    please use the pastebin –

    thanks for your answer,
    the context is that I want to output the posts of my custom taxonomies ordered by title, not by publication date… or what do you mean by context ?
    my query seems to work because the posts of my customs taxonomies “marque” are displayed by title, but twice…

    here is the full template :

    and a screenshot

    finally did something else, far more simple…

    	query_posts($query_string . '&orderby=title&order=ASC');
    <?php if (have_posts()) : ?>
    <?php while (have_posts()) : the_post(); ?>
    ... the rest

    it’s working for achive template and taxonomy template

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘wp_query outputting my posts twice’ is closed to new replies.