What is “main query”? [duplicate]

Your filter has a bug in it, namely when you call is_main_query, you’re not checking if the passed query is the main query, your checking if the currently active query is the main query, which will always be true. So instead try this: add_action( ‘pre_get_posts’, ‘some_name’); function some_name($query) { if ($query->is_front_page() && $query->is_main_query()) { $query->set( … Read more

Include WP_Query in my own PHP file?

Load WordPress in custom PHP Script: You need to load essential WordPress core functionality in your custom PHP script for WP_Query to work properly. For example, let’s say you have a custom PHP file named my-cron.php and WordPress is installed in the web root, like this: public_html/ index.php my-cron.php <– wp-load.php wp-settings.php … wp-admin/ wp-content/ … Read more

The next_posts_link() works only with original $wp_query

next_posts_link and previous_posts_link use the global $wp_query. function get_next_posts_link( $label = null, $max_page = 0 ) { global $paged, $wp_query; http://core.trac.wordpress.org/browser/tags/3.5/wp-includes/link-template.php#L1523 That means you need to do something like this to get those to work correctly. $orig_query = $wp_query; $wp_query = new WP_Query($args); // the rest of your code $wp_query = $orig_query; If you are … Read more

WP_Query vs get_posts

The difference between get_posts & WP_Query You can view get_posts() as a slimmed down WP_Query. In fact looking at the source: //… prepares query array $r $get_posts = new WP_Query; return $get_posts->query($r); get_posts() use WP_Query, but only returns an array of posts – nothing more. Furthermore it sets: $r[‘no_found_rows’] = true; Normally (by default with … Read more

How to use the_posts_navigation for wp_query and get_posts?

the_posts_navigation() is simply a wrapper function for get_the_posts_navigation() which issimply a wrapper function for paginate_links. The first two functions uses the the same exact parameters that is being used by paginate_links and actually passes it to the latter function as well get_the_posts_navigation() and the_posts_navigation() is good new functions as it eliminates a lot of custom … Read more

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