我当前正在显示一个带有“的页面列表”;“文字”;(英语学习网站)使用WP\\U查询。我想在列表的顶部添加一个搜索字段,但要以一种动态的方式(是AJAX吗?)修改以下列表以仅显示与搜索字段匹配的记录。
测试页面:https://pweyigm9.ayz.pl/baza-wiedzy/slownictwo-angielskie/czasowniki/czasowniki-nieregularne/
可视化(隐藏红色交叉记录,因为在“搜索字段”中有一个要查找的值):
$args = array(
\'post_type\' => \'post\',
\'post_status\' => \'publish\',
\'category_name\' => $postcat[0]->slug,
\'posts_per_page\' => 20,
\'orderby\' => \'meta_value title\',
\'meta_key\' => \'poziom\',
\'order\' => \'ASC\',
\'paged\' => $paged,
);
$arr_posts = new WP_Query( $args );
if ( $arr_posts->have_posts() ) :
echo \'<table class="vocab table table-bordered table-hover table-striped"><tbody><tr><th class="example">Infinitive</th><th class="example">Past simple</th><th class="example">Past participle</th><th class="example">polski</th></tr>\';
while ( $arr_posts->have_posts() ) :
$arr_posts->the_post();
?>
<?php
echo \'<tr><td>\';
echo do_shortcode(get_field(\'player1\'));
echo \'<a href="\'.get_permalink($item->ID).\'" title="\'.$postcat[0]->name.\': to \'.get_the_title($item->ID).\' - odmiana czasownika">\';
echo \'to \'.get_field(\'en1\');
echo \'</a></td><td>\';
echo do_shortcode(get_field(\'player2\')); echo get_field(\'en2\');
echo \'</td><td>\';
echo do_shortcode(get_field(\'player3\')); echo get_field(\'en3\');
echo \'</td><td>\';
echo \'<span class="float-right">\';
echo get_field(\'poziom\');
echo \'</span>\';
echo get_field(\'pl\');
echo \'</td></tr>\';
if (get_field(\'przyklad_en\')) {
echo \'<tr style="display:none;"><td></td></tr><tr class="en-vocab-example"><td colspan="2">\';
echo do_shortcode(get_field(\'przyklad_player\')); echo get_field(\'przyklad_en\');
echo \'</td><td colspan="2">\';
echo get_field(\'przyklad_pl\');
echo \'</td></tr>\';
}
?>
<?php
endwhile;
echo \'</tbody></table>\';
wp_pagenavi( array( \'query\' => $arr_posts ));
endif;