Does it make sense to assign functions like is_paged() to a variable rather than using it multiple times?

So, all query conditionals (is_paged, is_singular, etc) look something like this: function is_paged() { global $wp_query; if ( ! isset( $wp_query ) ) { _doing_it_wrong( __FUNCTION__, __( ‘Conditional query tags do not work before the query is run. Before then, they always return false.’ ), ‘3.1’ ); return false; } return $wp_query->is_paged(); } Globalize $wp_query … Read more

Get current page number of splitted article

For multi-page posts: The $page global variable returns the current page of a multi-page post. The $numpages global variable returns the total number of pages in a multi-page post. For paginated archive index pages: The $paged global variable returns the current page number of a paginated archive index. To use any of these variables, simply … Read more

Using $paged redirects /page/2 to page 1

If anyone comes across this issue, you can add this to your functions.php code add_filter(‘redirect_canonical’,’pif_disable_redirect_canonical’); function pif_disable_redirect_canonical($redirect_url) { if (is_singular()) $redirect_url = false; return $redirect_url; } Source

Customising rewrite rules for CPT single post URL to work as paged URL

Ok, so I got it working more or less correctly, although there is still a small problem left, please read on.. Here is what I’ve got: in fucntions.php: Rewrite rules add_action(‘init’, ‘my_rewrite_add_rewrites’); function my_rewrite_add_rewrites(){ add_rewrite_rule( ‘^services/([^/]+)/?$’, ‘index.php?post_type=service&order=ASC&orderby=menu_order’, ‘top’ ); add_rewrite_rule( ‘^services/([^/]+)/page/?([0-9]{1,})/?$’, ‘index.php?post_type=service&paged=$matches[2]&order=ASC&orderby=menu_order’, ‘top’ ); } Redirect rule add_action(“template_redirect”, ‘my_template_redirect’); function my_template_redirect(){ global $wp_query; // if … Read more

Paginate_links won’t create the right links on a taxonomy filtered custom post type archive

If, for example, I click on the “2”, the page loaded as removed my taxonomy filter(s) and paginate navigation “max-page” looks like (seems to be) the number of pages non filtered by taxonomy It’s not that the (taxonomy) filters are removed from the pagination links, but instead, the filters are actually never added because the … Read more

Pagination not working on custom query

The pagination functions work off of the main query, so you’d need to use pre_get_posts instead of creating a new query for them to work. But, you’re using WP_User_Query, so the standard pagination system will never work for you. You’re going to have to ‘roll your own’ pagination system here, and generate your own URLs … Read more

$wp_query->current_post restarts from zero on paged pages

$wp_query->current_post holds information about current post in loop, not global set of posts. Numering posts across multiple pages is not available natively (as far as I know) and probably would be to unreliable (for example what if number of posts per page changes is customized to be uneven?). For specific implementation building custom numbering, based … Read more

Customized first post techniques

You shouldn’t need to do any special queries for this. Here is one way to accomplish it /** * conditional check ensures special class only shows on top post on first page. * if you want top post on page 2, etc. to have special class, just set $first_post to true */ if( (int) get_query_var( … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)