How to paginate this custom loop? [duplicate]

Likely this is happening because you are using a custom page template. Try the following. I’ve commented the steps along the way. Hope it helps. <?php //get the current page $paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1; //pagination fixes prior to loop $temp = $query; $query = null; //custom loop using WP_Query $query = new … Read more

Pagination (page/2/) displaying 404 on archive pages

Found the answer!!! Put this in functions.php (or a required file). Of course, change it to suit your needs. I needed something that only worked for product category archives. function modify_product_cat_query( $query ) { if (!is_admin() && $query->is_tax(“product_cat”)){ $query->set(‘posts_per_page’, 2); } } add_action( ‘pre_get_posts’, ‘modify_product_cat_query’ ); I also took out the posts_per_page parameter from my … Read more

Adding Pagination on a Custom Author Page

Put the following code in your functions.php file. function limit_posts_per_page() { if ( is_author() ) // you can limit other pages as well ( i.e. is_archive() ), if need be. return 5; } add_filter( ‘pre_option_posts_per_page’, ‘limit_posts_per_page’ ); Make sure your using the author.php template, otherwise it wont work. Please have a look at twentyten’s author.php … Read more

Custom post type archive not regarding ‘posts_per_page’ => -1

WP_Query is for secondary loops. That is to say that it’s completely independent from the page’s default $wp_query. I suspect that it’s not working because you aren’t referencing your new WP_Query object on the loop. To do that, you’d do this: if( $all_sports->have_posts() ) : while( $all_sports->have_posts() ) : $all_sports->the_post(); // do stuff endwhile; endif; … Read more

How to load custom post archives sub-pages with ajax?

you might use the $.load and preventDefault() from jQuery. Assugming that you have .page-link link class on each url in pagination and you have all the posts in the #content div following code can help you to load the posts in that div on that particular page. $(“body”).on(“click”, “a.page-link”, function(e) { e.preventDefault(); $(“#content”).load($(this).attr(“href”) + ” … Read more

WordPress get pagination on wpdb get_results

You say “However, I know this is not a good way to do this” in your self answer. One thing I could add answering your question and using your answer is, you can use SQL_CALC_FOUND_ROWS with $wpdb $result = $wpdb->get_results( “SELECT SQL_CALC_FOUND_ROWS * FROM `wp_table` WHERE 1 LIMIT 10;” ); $total_count = $wpdb->get_var( “SELECT FOUND_ROWS();” … Read more

Pagination shows same contents all pages

Try changing $my_query to $wp_query to see if that fixes the issue. I found that when you rename the query it messes with the pagination. Also you should move the reset query after the pagination. Here’s a loop I’ve verified works with pagination: $args = array( ‘posts_per_page’ => 10, ‘post_type’ => ‘post’, ‘paged’ => get_query_var( … Read more

How can I paginate image attachments in a post?

I doubt you could paginate within a post display. It would be more effective to display all the image attachments at the page load, and have a script do the pagination. You can find a lot of them on such sites: http://www.themeflash.com/30-powerful-jquery-slideshow-sliders-plugins-and-tutorials/ You need to be able to edit your template files, specifically the header … Read more

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