Date based URLs for custom posts and pagination

Calling $GLOBALS[“wp_rewrite”]->flush_rules() did make everything work as I required but that wouldn’t be a good solution. Actually, you have to flush the rewrite rules after modifying them (i.e. also when registering custom post types). Also, you should never rely on these global variables. WordPress provides specific functions for nearly everything. For example, use flush_rewrite_rules() instead … Read more

WordPress AJAX Pagination with query_posts

In the end I found that it is not possible to update the pagination. The way I loaded the next lot of posts was by setting a post offset, and using a load more button. So in your ajax call where you are loading more posts, you need to pass over an offset value: $.ajax({ … Read more

Help making my pagination plugin better

Ok, here are some pointers: never run any meaningful code right from plugin body (especially don’t start queuing jQuery everywhere like you do – that’s asking for trouble), always do it at appropriate hooks; learn how to use $default argument in get_option() will save you a lot of typing there; learn how to use plugins_url() … Read more

Combining two wordpress queries with pagination is not working

You can try the following (untested): Setup the query arguments #1: (today) //—————– // Query part #1: //—————– $args1 = array( ‘post_type’ => ‘post’, ‘orderby’ => ‘comment_count’, ‘ignore_sticky_posts’ => 1, ‘date_query’ => array( array( ‘after’ => date(‘Y-m-d’), ), ‘inclusive’ => true, ) ); Setup the query arguments #2: (!today) //—————– // Query part #2: //—————– … Read more

Pagination adding page-numbers dots when using ‘mid_size’ => 0

Here’s a workaround: First change the paginate_links() output type to: ‘type’ => ‘array’, Then we can collect the previous, current and next parts from the paginate_links() output. Here’s a simple example where we target the relevant classes: $next=””; $current=””; $prev = ”; foreach( (array) $paginate_links as $link ) { if( false !== strpos( $link, ‘prev … Read more

Pagination throws 404 error on custom taxonomy archive pages

This function fixed the issue: function change_posttype() { if( is_archive() && !is_admin() ) { set_query_var( ‘post_type’, array( ‘post’, ‘portfolio’ ) ); } } add_action( ‘parse_query’, ‘change_posttype’ ); Then I just removed the paged and query_string function in my code and just left the regular loop 🙂

Custom Taxonomy not working with posts_per_page in new WP_query (pagination problem)

should it be.. $paged = (get_query_var(‘page’)) ? get_query_var(‘page’) : 1; WP_Query in codex: Pagination Note: You should set get_query_var( ‘page’ ); if you want your query to work with pagination. Since WordPress 3.0.2, you do get_query_var( ‘page’ ) instead of get_query_var( ‘paged’ ). The pagination parameter ‘paged’ for WP_Query() remains the same.

Skipping first 3 posts in wp query

For skipping the post just use offset parameter in wp_query. To display latest three post : <?php $latestpost = new WP_Query(‘order=asc&orderby=meta_value&meta_key=date&posts_per_page=3’); //Here add loop to display posts like while($latestpost->have_posts()) : $latestpost->the_post(); the_title(); the_content(); endwhile; wp_reset_query(); //After that skip three posts using offset $latestpost = new WP_Query(‘order=asc&orderby=meta_value&meta_key=date&posts_per_page=6&offset=3&paged=’ . $paged); the_title(); the_content(); endwhile; wp_reset_query(); ?> That’s it

Getting paginate_links() ‘end_size’ to display none

Here’s one suggestion: First we need to let paginate_links() return an array instead of a HTML list: ‘type’ => ‘array’, Then we can grab the output with: $paginate_links = paginate_links( $paginationArgs ); The plan is then to filter out the wanted links. Let’s get the current value: $c = $paginationArgs[‘current’]; We construct the search filter … Read more

Display “Page 3 of 5” for a paginated post

The current / total page count is set up by setup_postdata() which runs at the beginning of the loop. So, if you’re in the loop, all you have to do is this: global $page, $numpages; echo “Page $page of $numpages”; If you need to do that outside of the loop, do this first: global $page, … Read more

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