Remove the Homepage Query

The posts_request filter Skimming through the WP_Query we find this part of interest: if ( !$q[‘suppress_filters’] ) { /** * Filter the completed SQL query before sending. * * @since 2.0.0 * * @param array $request The complete SQL query. * @param WP_Query &$this The WP_Query instance (passed by reference). */ $this->request = apply_filters_ref_array( ‘posts_request’, … Read more

How can I fetch loop of post titles via AJAX?

you can wrap your function and hook it to ajax call like this: //if you want only logged in users to access this function use this hook add_action(‘wp_ajax_more_links’, ‘my_AJAX_more_links_function’); //if you want none logged in users to access this function use this hook add_action(‘wp_ajax_nopriv_more_links’, ‘my_AJAX_more_links_function’); function my_AJAX_more_links_function(){ check_ajax_referer(‘more_links’); $success_response = new WP_Ajax_Response(); $args = array(‘posts_per_page’ … Read more

Do I need to use The Loop on pages?

According to the Theme Guide, full loops should be used, even on single templates. Full loops must be used in all templates. Just calling the_post() in a template like single.php or page.php is not enough. So yes, it’s a best practice to use full loops.

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

AJAX with loop filtering categories

I know this is old, this looks exactly what I need, but isn’t working ATM. I paste everything on functions.php for a reason. ONE: Category Loop for theme file: Printed it with a shortcode, because i’m using bakery I wan’t to put it in an specific place in the site. This is Working fine. <?php … Read more

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