From 15f7c004c78ccaca073487e67c83ccf8ab5dc40e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ali=20=C3=87=C3=B6mez=20=7C=20Slaweally?= Date: Sun, 3 Nov 2024 01:15:26 +0300 Subject: [PATCH] Update search.php When the searched content is not found in the search results, it gives random content suggestions so that the blank page does not appear. we can determine the number of articles to be suggested in the settings. --- search.php | 91 ++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 78 insertions(+), 13 deletions(-) diff --git a/search.php b/search.php index bd87f7d..68867ac 100644 --- a/search.php +++ b/search.php @@ -3,28 +3,93 @@
- +

" . $year . "

"; - } - - // Now that your year has been printed, assign it to the $year_check variable - $year_check = $year; + // Assign the year to a variable + $year = get_the_date('Y', '', '', FALSE); + $year_link = get_year_link($year); + + // If your year hasn't been echoed earlier in the loop, echo it now + if (! isset($year_check) || $year !== $year_check) { + echo "

" . $year . "

"; + } + + // Now that your year has been printed, assign it to the $year_check variable + $year_check = $year; ?>
+ + +

+ + 0) : + ?> +
+ (int) $suggested_posts_count, + 'orderby' => 'rand' + )); + + if ( !empty($random_posts) ) : + foreach ( $random_posts as $post ) : + setup_postdata( $post ); + ?> +
+ +
+ +
+ + + + 0 ) ): ?> + + + + +
+ +
+
+ +

+ +

+ +
+ +
+ +
+ + +
+
+
+ No suggestions available.

'; + endif; + ?> +
+ + @@ -33,4 +98,4 @@ - \ No newline at end of file +