WordPress category & taxonomy loop with pagination

Don’t use ‘numberposts’=>-1 because numberposts is depracated moreover -1 shows all the post on one page. Instead use posts_per_page and set its value according to how many posts do you want. $paged= (get_query_var(‘paged’ )) ? get_query_var(‘paged’):1; global $query_string; $myquery = wp_parse_args($query_string); $myquery = array( ‘paged’ => $paged, ‘posts_per_page’=>10, ‘tax_query’ => array( ‘relation’ => ‘OR’, array( … Read more

Apply styling only to first page sticky posts

Strange that stickies aren’t completely unset from the main loop on paged pages but only on the first page. If we look at the source, we will see that stickies are only unset from the main loop if they are on the first page. So we have two options here depending on what you exactly … Read more

Three different post types on homepage

Since you’re not displaying a different amount of posts on the front page and on the paged pages for your main query, you don’t really need to mess around with the offset. All you need is to exclude the three posts you’ve already shown from your query, which you can do with the pre_get_posts action: … Read more

Add 20yrs to post date, and then query

An example, that uses the posts_where filter. If you need to extend a query using the posts_clauses filter, then just exchange $where with $pieces and set $pieces[‘where’] .= instead of $where .=. Just drop that into your functions.php file and add some conditional tag before querying the posts. function filter_where( $where ) { // Add … Read more