នៅពេលដែលយើងសរសេរពាក្យស្វែងរកការផ្សាយណាមួយ លទ្ធផលនៃការស្វែងរកនឹងត្រូវបង្ហាញនៅលើទំព័រពិសេសម៉្យាង ដែលយើងអាចហៅជាភាសាខ្មែរថា «ទំព័រស្វែងរក» ។ ហើយដើម្បីរចនាទំព័រស្វែងរកអោយមានរូបរាងទៅតាមការចង់បានរបស់យើង ជាដំបូងយើងត្រូវបើកឯកសារឈ្មោះ search.php និងសរសេរកូដមួយចំនួននៅក្នុងឯកសារនោះ ដូចខាងក្រោមនេះ៖
<?php /** * The template for displaying search results pages * * @link https://developer.wordpress.org/themes/basics/template-hierarchy/#search-result * * @package Lotus_Blue */ get_header(); ?> <?php if(!wp_is_mobile()){ get_template_part( 'template-parts/home', 'ad' ); } ?><?php get_sidebar(); get_footer(); <?php if ( have_posts() ) : ?> <?php /* Start the Loop */ while ( have_posts() ) : the_post(); /** * Run the loop for the search to output the results. * If you want to overload this in a child theme then include a file * called content-search.php and that will be used instead. */ get_template_part( 'template-parts/content', 'search' ); endwhile; the_posts_navigation(); else : get_template_part( 'template-parts/content', 'none' ); endif; ?> <?php /* translators: %s: search query. */ printf( esc_html__( 'លទ្ធផលនៃការស្វែងរកពាក្យ: %s', 'lotus-blue' ), '' . get_search_query() . '' ); ?>
បន្ទាប់មកទៀត យើងចាំបាច់ត្រូវបើកឯកសារមានឈ្មោះថា content-search.php នៅក្នុងថត template-parts រួចសរសេរកូដមួយចំនួនដូចខាងក្រោមនេះ៖
<?php /** * Template part for displaying results in search pages * * @link https://developer.wordpress.org/themes/basics/template-hierarchy/ * * @package Lotus_Blue */ ?> <article id="post-" <?php post_class(); ?>><?php the_title( sprintf( ' </article>', esc_url( get_permalink() ) ), '
' ); ?> <?php if ( 'post' === get_post_type() ) : ?> <?php endif; ?>