Pagination in WP query with transient API
Did you try this? $paged1 = (get_query_var(‘page’)) ? get_query_var(‘page’) : 1;
Did you try this? $paged1 = (get_query_var(‘page’)) ? get_query_var(‘page’) : 1;
As of WordPress 3.6 you can put comma-delimited entries in the category_name property of the arguments array like this: $args = array( ‘category_name’ => ‘news2014,news2015’, ); query_posts($args); This works if the categories are both at the root level (no parent)
Try adding the type parameter: $args = array(‘post__not_in’ => $exclude, ‘ignore_sticky_posts’ => 1, ‘posts_per_page’ => 5, ‘meta_query’=> array( array( ‘key’=>’my_featured_post’, ‘value’=> 1, ‘type’ => ‘numeric’, // assuming your custom_value is an int, not a string. ‘compare’=>’!=’ ) ) ); $query = new WP_Query($args);
May be this will help: …….. …….. if(isset($_POST[‘genre’])) { $myquery = array( ‘showposts’ => 20 , ‘orderby’ => ‘title’, ‘order’ => ‘ASC’, ‘paged’ => $paged, ‘tax_query’ => array( ‘relation’ => ‘AND’, array( ‘taxonomy’ => ‘anime_genre’, ‘terms’ => $_POST[‘genre’], ‘field’ => ‘slug’, ‘operator’ =>’AND’ ) ) ); } query_posts($myquery); ……
I’m not entirely sure why the get_posts() function works instead of creating a new instance of WP_QUERY. From what I understand about how WordPress queries work, get_posts() is actually creating it’s own instance of WP_QUERY anyhow. Either way, here is the solution that I’m using currently. <?php //GET THE PHOTOGRAPHERS $args = array( ‘post_type’ => … Read more
Add a ‘posts_per_page’=>6 variable to the array that you’re passing to your get_posts query.
Doing a Select Count(*) … will only ever output one row with a single value – the number of rows that satisfied your where clause.
Just open the comments.php file from your theme. Find the following line (or similar) <?php foreach ($comments as $comment) : ?> Add this lines just above it if (isset($_GET[‘comOrder’]) && $_GET[‘comOrder’] == ‘Newest’ ) $comments = array_reverse($comments, true); so your code looks like this: <?php if (isset($_GET[‘comOrder’]) && $_GET[‘comOrder’] == ‘Newest’ ) $comments = array_reverse($comments, … Read more
Yeah, I did something like this recently, but this is how I did it: $showNum = 10; $startNum = 0; if($paged > 0){ $pageNum = $paged – 1; $startNum = $pageNum * $showNum; } elseif($paged == 0){ $paged = 1; } Then I went ahead and used the modified $paged value to request entries within … Read more
If you want to plug into the query, pre_get_posts() is going to be your friend. Pippin Williamson also has a great writeup on the subject.