文章目录
本文最后更新于 2022-10-14,已超过 365 天未更新,内容可能已失效。
ripro主题首页搜索框,输入关键字后,最多会弹出5个相关的结果。

有的喜欢多显示几个,那么要怎么修改呢?

其实很简单

修改目录ripro/inc/core-ajax.php 84行,下列代码修改弹出8个相关结果~~

好了教程就到这里,根据自己的喜好修改吧

function ajax_search()
{
    global $wp_query;
    header('Content-type:application/json; Charset=utf-8');
    $text   = !empty($_POST['text']) ? esc_sql($_POST['text']) : null;
    $args = array('s' => $text,'posts_per_page' => 8);
    $array_posts = array ();
    $data = new WP_Query($args);
    while ( $data->have_posts() ) : $data->the_post();
        array_push($array_posts, array("title"=>get_the_title(),"url"=>get_permalink(),"img"=>_get_post_timthumb_src() )); 
    endwhile;
    echo json_encode($array_posts);
    exit();
}

 

CC 许可协议
署名-非商业性使用-相同方式共享 4.0 国际 了解协议
文章链接:https://zptheme.com/2659.html
本文作者:子佩·来源:子佩工作室

除非注明,子佩工作室 文章均为原创,转载请以链接形式标明本文地址。

相关推荐

登录后即可发表评论

社交账号登录

全部评论 (0)