Hot answers tagged

3

I finally found a fix: just need to replace this: the_posts_pagination( array( 'mid_size' => 2 ) ); with: echo paginate_links( array( 'total' => $query->max_num_pages, 'mid_size' => 2 ));


3

EDIT I have played around with a possible solution to your issue. We can try the following Add our own action to template_redirect where we do the following Check that the current request is a paged single post page and that we do not have the <!--nextpage--> tag in the post content. If everything checks out in our condition, we will do a manual ...


2

You should use pre_get_post action to alter the search query. It is much better approach and you will avoid unnecesary queries (actually, with your code, WordPress already performed the database query for the current request but you discard it and perform a new database query). add_action( 'pre_get_posts', 'custom_search_query' ); function ...


2

Hm. Have you thought about doing some URL rewrites in .htaccess? RewriteRule ^category/bar-talk/page/([0-9]+)$ /bar-talk/drink-number/$1 [L,R=301] RewriteRule ^bar-talk/drink-number/([0-9]+)$ /index.php?category_name=bar-talk&page=$1 [L] // @drizzlyowl


1

You should consider the POST request method for your action. Otherwise you might try to hijack the set_url_scheme filter with: add_filter( 'set_url_scheme', 'wpse_remove_arg' ); function wpse_remove_arg( $url ) { return remove_query_arg( 'do_action_xyz', $url ); } Then you could try to narrow the scope and only run this on the corresponding table ...


1

You don't need a custom query to include CPTs in homepage posts in normal cases. Just use pre_get_posts. function wpse215208_include_all_cpt( $query ) { if ( is_home() && $query->is_main_query() ) { $query->set('post_type', array( 'post', 'photo', 'video', 'web' ) ); } } add_action('pre_get_posts', ...


1

You are doing it wrong You should translate the HTML string, not the function When passing strings into functions, like what you are doing, you should use __() which returns the translated string. _e() would echo the string and you would get the raw text and the modified text on output Example of correct usage: get_next_posts_link( __( 'Older posts' ), ...


1

the_posts_pagination uses global query and global query does not have pagination. So it is the correct behavior of WordPress. To overcome from this problem assign custom query to global query then after looping again restore the global query. function foo($args){ $post_type = $args['post_type']; global $wp_query; $original_query = $wp_query; ...


1

Thank you all, guys. I've solved it this way: added $paged variable: $paged = ( get_query_var('page') ) ? get_query_var('page') : 1; (for main page you should use get_query_var('page'), for other pages - $paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1; ) And added a new argument for WP_Query: 'paged' => $paged My code now: function ...



Only top voted, non community-wiki answers of a minimum length are eligible