New answers tagged

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 ...


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; ...


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 ...


1

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 ...


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' ), ...


0

Paste this code into your functions.php and it will be solved. add_action('add_to_cart_redirect', 'resolve_dupes_add_to_cart_redirect'); function resolve_dupes_add_to_cart_redirect($url = false) { if(!empty($url)) { return $url; } return get_bloginfo('wpurl').add_query_arg(array(), remove_query_arg('add-to-cart')); }


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 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 ...


0

Okay, currently using this craziness. A combination of the "page" rewrite and modified WP No Category Base plugin. Seems to be working perfectly. /*=========================================================== = REMOVE CATEGORY / CUSTOM PAGINATION = ===========================================================*/ ...


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


0

Add this two lines to your theme's function.php file and everything will get back to work: add_filter(‘redirect_canonical’,’custom_disable_redirect_canonical’); function custom_disable_redirect_canonical($redirect_url) {if (is_paged() && is_singular()) $redirect_url = false; return $redirect_url; }


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 ));


-2

<?php global $wpdb, $paged; query_posts($query_string . '&posts_per_page=9'); $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $author = isset($_GET['author_name']) ? get_userdatabylogin($author_name) : get_userdata(intval($author)); query_posts($query_string . '&posts_per_page=9'); $args = array( 'post_type' => 'post', ...



Top 50 recent answers are included