Redirect Search Result
-
The following code is the code of my search.php and if the search has no result (no posts found) i want it to redirect to another page like https://www.example.com… What i must change?
<?php get_header() ?> <div class="sleeve_main"> <div id="main"> <h2><?php printf( __( 'Search Results for: %s', 'p2' ), esc_html( get_search_query() ) ); ?></h2> <?php if ( have_posts() ) : ?> <ul id="postlist"> <?php while ( have_posts() ) : the_post() ?> <?php p2_load_entry() // loads entry.php ?> <?php endwhile; ?> </ul> <?php else : ?> <div class="no-posts"> <h3><?php _e( 'No posts found!', 'p2' ) ?></h3> </div> <?php endif ?> <div class="navigation"> <p><?php posts_nav_link( ' | ', __( '← Newer Posts', 'p2' ), __( 'Older Posts →', 'p2' ) ); ?></p> </div> </div> <!-- main --> </div> <!-- sleeve --> <?php get_footer() ?>
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Redirect Search Result’ is closed to new replies.