WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This is my code, why cant i get post per page and offset result ?.

    $myquery['tax_query'] = array(
        'relation' => 'OR',
        'posts_per_page' => 3,
        'offset' => 3,
        'taxonomy' => 'brands',
        'terms' => array('iHOME'),
        'field' => 'slug',
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<?php the_post_thumbnail();?>
<b><?php the_title();?></b>
<p><?php echo excerpt(25); ?></p>
<?php echo esc_html( get_post_meta( get_the_ID(), 'category', true ) ); ?>

<?php endwhile; else: ?>
<?php endif; ?>
share|improve this question
it's <?php not >?php – JMau Jun 30 '13 at 12:50
@ShihabMalayil here is your solution: MARKDOWN HELP. Please, get into a habit to write your questions nicely. – Eugene Manuilov Jun 30 '13 at 13:06
@Eugene Manuilov- THANK YOU – Shihab Malayil Jun 30 '13 at 13:12

Your query args are messed up. Posts per page and offset params are not part of the tax_query array. Check out the example in the Codex:

$args = array( 
    'post_type' => array('your_cpt'),
    'posts_per_page' => 3,
    'offset' => 3,
    'tax_query' => array(
       'relation' => 'OR',
            'taxonomy' => 'brands',
            'terms' => array('iHOME'),
            'field' => 'slug',

$tax_query = new WP_Query($args);

if ( $tax_query->have_posts() ) : while ( $tax_query->have_posts() ) : $tax_query->the_post(); 

    echo excerpt(25); 
    echo esc_html( get_post_meta( get_the_ID(), 'category', true ) ); 

endwhile; else: 


Also, I couldn't really explain why, but I always see it written around here to avoid using query_posts, so I replaced that in my answer with new WP_Query.

One more thing, if you are querying for a post type other than posts, you'll need to define the post_type query parameter.

share|improve this answer
sure, it's CPT. -Thank you- – Shihab Malayil Jun 30 '13 at 14:04
@helgatheviking- You are correct. 'tax_query' => array( . thank you very much. expecting more....! – Shihab Malayil Jun 30 '13 at 14:11
What are you expecting more of? The code should work now. – helgatheviking Jun 30 '13 at 14:14
iam sorry, i mean help me next time. thank you. tax_query' => array( ,you just missed =>. – Shihab Malayil Jun 30 '13 at 14:16
We'll see. I'm only on here some of the time. Fixed the typo. Don't forget to mark as resolved if this solves your question. – helgatheviking Jun 30 '13 at 14:25

Your Answer


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.