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


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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.