How do I toggle pagination on/off in search results and category listings via a link?

I think it should work by hooking into pre_get_posts: function wpse_254661_remove_pagination( $query ) { if ( $query->is_main_query() && get_query_var( ‘onepageprint’, 0 ) ) { $query->query_vars[‘nopaging’] = 1; $query->query_vars[‘posts_per_page’] = -1; } } add_action( ‘pre_get_posts’, ‘wpse_254661_remove_pagination’ ); Like this you can modify your query right before it gets fetched and the query object gets passed by … Read more

Empty search results return soft 404

Use a web service such as W3C Link Checker to find out the broken links and fix it. Also based on what you described, if it a self-developed theme and caused due to search, make sure you will have a content template that handle the none content situation. You can check your theme’s search.php and … Read more

WordPress search results with Ajax, get_post_type() not working

$_GET[‘s’] will not work for two reason. Firstly you make a POST request and not a GET request and secondly there is no variable with name s in your request. When executing an AJAX request through wp-admin/admin-ajax.php WordPress executes only the code (function) registered to that request. Also it loads WordPress Administration APIs and Ajax … Read more