How to disable Wp-Page Navigation on Blank Search in Wordpress

Im using the Following Code in search.php

?php if (have_posts()  strlen( trim(get_search_query()) ) != 0 ) : while (have_posts()) : the_post(); ?

?php endwhile; else:? bNo results match your search./b pFor Accurate results, Please Search the Model Number of the device or the Brand Name./p ?php endif; ?

div class="navigation"?php if(function_exists('wp_pagenavi')) { wp_pagenavi(); } else { ? ?php } ?/div

Functions.php:

function SearchFilter($query) {
    // If 's' request variable is set but empty
    if (isset($_GET['s'])  empty($_GET['s'])  $query-is_main_query()){
        $query-is_search = true;
        $query-is_home = false;
    }
    return $query;}
add_filter('pre_get_posts','SearchFilter');

How to disable the navigation in black search?

Topic codex Wordpress

Category Web


Can you try this at search.php

<?php if ( have_posts() && strlen( trim( get_search_query() ) ) != 0 ) : while ( have_posts() ) : the_post();  // Start of the loop.?>
    <?php  // Do code for the loop. ?>
<?php endwhile;  // End of the loop. ?>
    <div class="navigation">
        <?php 
            if( function_exists( 'wp_pagenavi' ) ) { 
                wp_pagenavi(); 
            }
        ?>
    </div>
<?php else:?> 
    <b>No results match your search.</b> 
    <p>For Accurate results, Please Search the Model Number of the device or the Brand Name.</p> 
<?php 
endif; 
?>

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.