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.

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
add comment

1 Answer

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