WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. thomas
    Member
    Posted 1 year ago #

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

  2. alchymyth
    The Sweeper & Moderator
    Posted 1 year 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
    Member
    Posted 1 year 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
    Member
    Posted 1 year ago #

    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

Topic Closed

This topic has been closed to new replies.

About this Topic