Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add dynamically number of posts in a query in wordpress

Tags:

php

wordpress

I have the following query in my slider

<?php query_posts( 'category_name=Uncategorized&posts_per_page=3' );

and instead of 3 i need to add dynamically the posts_per_page. For triggering an option for my functions.php theme i usually do

<?php $settings = get_option('mytheme_options'); echo $settings['postspage'];?>

I have tried

<?php 
 query_posts('category_name=Uncategorized&posts_per_page=$settings["postspage"]'); 
?>

and it doesn't do anything or echo any error

like image 805
Adrian Avatar asked Oct 21 '22 20:10

Adrian


1 Answers

$postsPage = $settings["postspage"];
query_posts('category_name=Uncategorized&posts_per_page='.$postsPage); 
like image 100
ggdx Avatar answered Oct 23 '22 16:10

ggdx