כדי להוסיף תמונות לתוצאות החיפוש, יש לערוך את הקובץ search.php תחת עיצוב > עריכת תבנית.
יש להחליף את הקוד הבא (שורה 36):
the_post(); ?> <div id="post-<?php the_ID(); ?>" <?php post_class( array('post-item', 'clearfix', 'no-img') ); ?>>
בקוד הכולל קישור, תמונה, בדיקה שהיא קיימת, ועדכון ה-Class בהתאמה: (יש לשים לב לשים את קוד ה-PHP לפני הסוגר, בשורה אחרי ה-the_post)
$imgis = has_post_thumbnail(); ?> <div id="post-<?php the_ID(); ?>" <?php post_class( array('post-item', 'clearfix', 'img') ); ?>> <a href="<?php the_permalink(); ?>"> <div class="image_frame post-photo-wrapper scale-with-grid <?php echo esc_attr($post_format); ?>"> <div class="image_wrapper"> <?php if ($imgis) { the_post_thumbnail('medium-large'); } else { echo '<img width="500" height="250" src="http://abone.aitech.co.il/wp-content/uploads/2021/06/metbach-mao.jpg" class="scale-with-grid wp-post-image" alt="">'; } ?> </div> </div></a>
כאשר יש להגדיר את התמונה שמופיעה כמחזיק מקום – כאשר אין תמונה מובילה לאותו עמוד / פוסט.
ניתן לסגנן את תוצאות החיפוש עם קודי CSS הבאים: (הגבלת גובה תמונות, הוספת מרווח עליון)
.search-results #Content .image_wrapper { max-height:250px; } .search-results #Content { padding-top:50px !important; }
או לחלופין הגבלת רוחב (לשים בטווח הלא-סלולרי):
.search-results #Content .image_frame { max-width:250px; margin-left:30px; margin-right:100px; }