• I am working on modifying the plugin pbd-ajax-load-posts for wordpress. It works great but I am trying to change the query it uses on the database. so far my attempts have not worked. The new query itself works great and pulls the posts as I want them to, but when I want pagination done with the plugin, the plugin is not using this query to get the posts, its using the standard query wordpress uses. How would I change this?

    Here is the blog on the plugin itself, explaining it.

    https://www.problogdesign.com/wordpress/load-next-wordpress-posts-with-ajax/

    Here is the code I am trying to add:

    $itemResults = $wpdb->get_results("CUSTOM_QUERY", OBJECT); // query works fine
    
                    $post_id_array = array();
                    foreach ($itemResults as $posts_info) {
                        $post_id_array[] = $posts_info->ID;
                    }
    
                    $args = array('post__in' => $post_id_array, 'orderby' => 'post__in', 'posts_per_page' => 5,'paged' => get_query_var( 'paged' ));
                    $popular_post_query = new WP_Query( $args );
                    $max = $popular_post_query->max_num_pages;

    The plugin uses next_posts($max, false) to assemble a link for the next page it should load via ajax.

    Any ideas would be greatly appreciated

  • The topic ‘pbd-ajax-load-posts change query’ is closed to new replies.