Pagination for Custom WP_Query not displaying page 2 results

Rather than try to wrestle with the default search query, I would take a different approach and create a custom search function. First, we add a new custom search query var, in this case search_var. Then we add a couple of rewrite rules so we can have URLs like: http://example.com/custom-search/1991/ http://example.com/custom-search/1991/page/2/ with this function: function … Read more

How can I change the output display of my pagination?

I could see that you are trying to achieve the following output: <div class=”pagination”> <span>Page {current} of {total pages}</span> {links here} </div> And you attempted it like so: ‘before_page_number’ => ‘<div class=”pagination”><span>Page ‘. // wrapped for clarity $paged .’ of ‘ . $term->max_num_pages . ‘</span></div>’ But that will actually add the markup before each and … Read more

Pagination on custom post type on front-page.php

The root problem here is the call to query_posts: $args = array(‘post_type’ => array(‘posts’, ‘affiliate-products’)); query_posts($args); At no point do you tell it which page to fetch, so it always fetches the first page, aka the default. You could add this, but fundamentally, the entire approach is incorrect, and has many other problems you might … Read more

Hide Load more Ajax button if there is no more users to load or less than the number?

I think something like this may work, if response is just HTML and returns an empty string ” when there are no more results: <script type=”text/javascript”> var ajaxurl = “<?php echo admin_url( ‘admin-ajax.php’ ); ?>”; var page = 2; jQuery(function($) { $(‘body’).on(‘click’, ‘.loadmorefollowing’, function() { var data = { ‘action’: ‘user_following_by_ajax’, ‘page’: page, ‘security’: ‘<?php … Read more

The paging is very slow under a large number of articles

The two most obvious things you can do to reduce the load time of this query are the IN statement and the offset in your LIMIT statement. The larger the number of items you’re checking for in the IN statement, the less efficient the query. See: https://stackoverflow.com/questions/4514697/mysql-in-operator-performance-on-large-number-of-values The reason the offset is causing performance issues … Read more

Custom category.php paging shows the same posts

This should be $args = array(‘category’ => 11, ‘posts_per_page’ => 2, ‘order_by’ => ‘date’); like this $paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1; $args = array(‘category’ => 11, ‘posts_per_page’ => 2, ‘order_by’ => ‘date’, ‘paged’ => $paged);

404 Not Found

Not Found

The requested URL was not found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.