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

I have a page template and at the bottom, I want a loop of posts based on a custom field value - store_name

This is what I have:

    global $wp_query;
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    query_posts(array('posts_per_page' => '10','paged'=>$paged,'category_name'=>'<?php echo get_post_meta($post->ID, 'store_name', true); ?>'));

But of course that doesn't work because I know my syntax is incorrect with the nested php statement, but how do I fix it?

share|improve this question


Got it working with:

                    global $wp_query;

                    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;

                    $store_name = (get_post_meta($post->ID, 'store_name', true));

                    query_posts(array('posts_per_page' => '10','paged'=>$paged,'category_name'=>$store_name));
share|improve this answer

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.