How to check if I’m on the last page of posts?

The WP_Query object contains a max_num_pages field which contains how many pages of posts there are. You can compare the current page number with it. (This is how get_next_posts_link() does it.) global $wp_query; $current_page = $wp_query->get( ‘paged’ ); if ( ! $current_page ) { $current_page = 1; } if ( $current_page == $wp_query->max_num_pages ) { … Read more

Multiple WP_Query loops with Pagination

Yes, it can be done. The key is to make the format parameter different for the two queries: <!– Cats –> <div class=”animals”> <? $paged1 = isset( $_GET[‘paged1’] ) ? (int) $_GET[‘paged1’] : 1; $paged2 = isset( $_GET[‘paged2’] ) ? (int) $_GET[‘paged2’] : 1; // Custom Loop with Pagination 1 // http://codex.wordpress.org/Class_Reference/WP_Query#Usage $args1 = array( … Read more

How to get posts published between a date and today?

UPDATE December 23 2014 There is a better method using date_query property of WP_Query class: $args = array( ‘post_type’ => ‘post’, ‘tax_query’ => array( array( ‘taxonomy’ => ‘post_format’, ‘field’ => ‘slug’, ‘terms’ => array( ‘post-format-image’ ) ) ), ‘cat’ => ‘-173’, ‘post_status’ => ‘publish’, ‘date_query’ => array( ‘column’ => ‘post_date’, ‘after’ => ‘- 30 days’ … Read more

How to get Author ID outside the loop

The simplest and most straightforward way to get the post author ID outside the loop, if you know the post ID, is to use the WordPress core function get_post_field(). $post_author_id = get_post_field( ‘post_author’, $post_id ); If you do not yet know the post ID of the page you are on, then since WP 3.1 the … Read more

Get the children of the parent category

You can’t just pass the string “parent” to get_categories. You have to pass the ID of the parent. $categories=get_categories( array( ‘parent’ => $cat->cat_ID ) ); Notice that there are two similar but not equal “get child” parameters that you can use. child_of (integer) Display all categories that are descendants (i.e. children & grandchildren) of the … Read more

deneme bonusu veren sitelerbahis casinomakrobetceltabetpinbahispolobetpolobet girişpinbahis girişmakrobet girişpulibet girişmobilbahis girişkolaybet giriş