Support » Fixing WordPress » wp_query outputting my posts twice

  • Resolved thomas

    (@beloutte)


    hello

    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 :

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

    have I done something wrong ?…

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

    (@alchymyth)

    Forum Moderator

    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

    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

    hey,
    finally did something else, far more simple…

    <?php
    	wp_reset_postdata();
    	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.