[resolved] wp_query outputting my posts twice (4 posts)

  1. thomas
    Posted 3 years ago #


    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 ?...

  2. Michael
    Forum Moderator
    Posted 3 years ago #

    what is the context of that code?

    please post the full code of the template.

    please use the pastebin - http://codex.wordpress.org/Forum_Welcome#Posting_Code

  3. thomas
    Posted 3 years ago #

    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 : http://pastebin.com/usZxS1RP

    and a screenshot

  4. thomas
    Posted 3 years ago #

    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

Topic Closed

This topic has been closed to new replies.

About this Topic