Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

My loop don't display my all relevant posts, It's should display the all posts which started w/specific letter (if it " " then it's should display the all posts sorted by popularity) what's wrong w/it?

 $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
 if ($first_letter!=' ') { $args = array (
        'posts_per_page' => $posts_per_page,
        'taxonomy' => $term->taxonomy,
        'term' => $term->name,
        'post_type' => $post_type,
        'orderby' => 'title',
        'order' => 'ASC',
        'paged' => $paged); }
    else {$args = array (
        'posts_per_page' => $posts_per_page,
        'taxonomy' => $term->taxonomy,
        'term' => $term->name,
        'post_type' => $post_type,
        'meta_key' => 'post_views_count',
        'orderby' => 'meta_value_num',
        'showposts' => 160,
        'order' => 'DESC',
        'paged' => $paged); }

 $the_query = new WP_Query( $args );

 $mam_global_where = ''; // Turn off filter
 if ( $the_query->have_posts() ) {
    $in_this_row = 0;
    while ( $the_query->have_posts() ) {
        $the_query->the_post();
        if ($first_letter!=' '&&$first_letter!='') { $first_letter = strtoupper(substr(apply_filters('the_title',$post->post_title),0,1));}
        if ($first_letter != $curr_letter) {
            if (++$post_count > 1) { end_prev_letter(); }
            start_new_letter($first_letter);
            $curr_letter = $first_letter;
            }
        if (++$in_this_row > $posts_per_row) {
            end_prev_row();
            start_new_row();
            ++$in_this_row; // Account for this first post
            } ?>
    <a href="<?php the_permalink(); ?>" rel=.....</a>   
    </div> <!--end #post-->
    <?php }
 end_prev_letter();
share|improve this question
1  
Exactly what part of this code doesn't work? Also, there are several functions used by that code that you have not posted. That makes this impossible to test and debug accurately. –  s_ha_dum Jun 11 '13 at 14:52
    
What @s_ha_dum said. Please describe what works and what doesn't work. What did you do to debug? Did you pare your code down to just the taxonomy parameters, in order to eliminate any other potential issues? –  Chip Bennett Jun 11 '13 at 15:23
add comment

1 Answer

Your taxonomy and term arguments are incorrect. The preferred method is via tax_query

$args = array(
    // ... other args
    'tax_query' => array(
        array(
            'taxonomy' => $term->taxonomy,
            'field' => 'slug',
            'terms' => $term->name
        )
    )
);

Please see WP_Query for all valid arguments and their correct formatting.

share|improve this answer
    
Thanks for your comments. Milo, I tried your change and it's help :( Well, this code it's part of my taxonomy.php and all I want to do is to display and list of my posts by the first letter. here you can find it: bmobile.co.il (and choose the taxonomy). thanks for your support!!!! –  RonandVam Jun 14 '13 at 6:48
add comment

Your Answer

 
discard

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.