Pagination doesn’t work in custom page template [duplicate]

Try the following and see how you go.. <?php global $paged; global $wp_query; $temp = $wp_query; $wp_query = null; $wp_query = new WP_Query(); $wp_query->query(‘posts_per_page=10&post_type=your_post_type’.’&paged=’.$paged); while ($wp_query->have_posts()) : $wp_query->the_post(); ?> <!– do your loop output here, title, content etc –> <?php endwhile; ?> <?php previous_posts_link(‘&laquo; Newer’) ?> <?php next_posts_link(‘Older &raquo;’) ?> <?php $wp_query = null; $wp_query … Read more

Different amount of posts on homepage than paged pages

You should use the pre_get_posts filter. You can exclude the homepage with ! is_front_page or ! is_home depending on your configuration. /** * Changes the number of posts per page if not is_home * * @author SFNdesign, Curtis McHale */ function wptt_change_posts_on_page( $query ) { if ( ! is_home() && $query->is_main_query() ) { $query->set( ‘posts_per_page’, … Read more

How to no follow the paginated comments

There are two special filters for that: add_filter( ‘previous_comments_link_attributes’, ‘wpse_77217_comment_nofollow’ ); add_filter( ‘next_comments_link_attributes’, ‘wpse_77217_comment_nofollow’ ); function wpse_77217_comment_nofollow() { return ‘ rel=”nofollow”‘; }

Jetpack Infinite scroll conflicting with theme’s pre_get_posts custom posts_per_page

You’ve specified a priority of 1 for your pre_get_posts function here: add_action( ‘pre_get_posts’, ‘mytheme_portfolio_archive_pages’, 1 ); Jetpack doesn’t specify a priority: add_action( ‘pre_get_posts’, array( $this, ‘posts_per_page_query’ ) ); So that gets added with the default priority for add_action, which is 10: $priority (int) (optional) Used to specify the order in which the functions associated with … Read more

How to check if comments are paginated?

Just some additional info for the main comment query: Since you mentioned the global $wp_query object, we can see that it stores: $wp_query->max_num_comment_pages = $comment_query->max_num_pages; in the main comment query in the comments template. There exists a wrapper for this, namely: get_comment_pages_count(); that’s available after the main comment query. If we need it before the … Read more

Is there any way to override “break comments into pages” and “close comments for old posts” on certain posts, but not on others?

The option_{$option_name} filter can be used to modify the value of an option on the fly. Replace {$option_name} with the name of the option to be modified. Override Comment Pagination Option The option name for paginating comments is page_comments, so we’ll create a filter called option_page_comments. In the example below, we check if we’re looking … Read more

Edit pagination text in the get_the_posts_pagination function

You can modify screen_reader_text argument when invoking the_posts_pagination() wrapper function in your theme files: <?php the_posts_pagination( array( ‘mid_size’ => 2, ‘prev_text’ => __( ‘Back’, ‘textdomain’ ), ‘next_text’ => __( ‘Onward’, ‘textdomain’ ), ‘screen_reader_text’ => __( ‘Whatever’, ‘textdomain’ ), ) ); ?> Search for the_posts_pagination in your template files, and adjust texts as you wish.

Pagination for custom query on single.php

Well, for anyone else looking to solve a similar problem, I found this post, and it led me in the right direction: http://wordpress.org/support/topic/pagination-on-singlephp-causing-301-redirect?replies=9. I added this snippet of code to my functions.php, and I can paginate in custom queries without issue on single.php now. I don’t know enough about it to know what it does, … Read more

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