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 am creating an option page for one of my wordpress themes and I am trying to ask user to enter "Number of posts to show" -

I am using "query_posts" to show posts This is the code I modified but it is not working

<?php query_posts("posts_per_page='".of_get_option('numberofposts', '3' )."'&cat='".of_get_option('postcategory', 'no entry' )."'"); while(have_posts()) : the_post();?>

the correct method to echo the option used is :

<?php echo of_get_option('numberofposts', 'no entry' ); ?>

which returns a value the user entered - ex : 5

the category section works , I can output the category ID but not the number of posts .

thanks in advanced

share|improve this question
up vote 3 down vote accepted

You have the value of posts per page in single quotes, remove the quotes and it will work.

That said, you should be altering the main query with pre_get_posts instead of query_posts.

share|improve this answer
Thank you so much ! it worked like a charm ;) – Dave Jul 20 '12 at 22:11

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.