These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /** |
||
3 | * The template for displaying search results pages. |
||
4 | * |
||
5 | * @link https://developer.wordpress.org/themes/basics/template-hierarchy/#search-result |
||
6 | * |
||
7 | * @package Lighthouse |
||
8 | */ |
||
9 | |||
10 | get_header(); ?> |
||
11 | |||
12 | <section id="primary" class="content-area"> |
||
13 | <main id="main" class="site-main" role="main"> |
||
14 | |||
15 | <?php |
||
16 | View Code Duplication | if ( have_posts() ) : ?> |
|
0 ignored issues
–
show
|
|||
17 | |||
18 | <header class="page-header"> |
||
19 | <h1 class="page-title"><?php printf( esc_html__( 'Search Results for: %s', 'lighthouse' ), '<span>' . get_search_query() . '</span>' ); ?></h1> |
||
20 | </header><!-- .page-header --> |
||
21 | |||
22 | <?php |
||
23 | /* Start the Loop */ |
||
24 | while ( have_posts() ) : the_post(); |
||
25 | |||
26 | /** |
||
27 | * Run the loop for the search to output the results. |
||
28 | * If you want to overload this in a child theme then include a file |
||
29 | * called content-search.php and that will be used instead. |
||
30 | */ |
||
31 | get_template_part( 'template-parts/content', 'search' ); |
||
32 | |||
33 | endwhile; |
||
34 | |||
35 | the_posts_navigation(); |
||
36 | |||
37 | else : |
||
38 | |||
39 | get_template_part( 'template-parts/content', 'none' ); |
||
40 | |||
41 | endif; ?> |
||
42 | |||
43 | </main><!-- #main --> |
||
44 | </section><!-- #primary --> |
||
45 | |||
46 | <?php |
||
47 | get_sidebar(); |
||
48 | get_footer(); |
||
49 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.