【问题标题】:Wordpress Olam theme - Want to change search functionWordpress Olam 主题 - 想要更改搜索功能
【发布时间】:2018-11-21 08:26:35
【问题描述】:

我想更改 word-press 搜索逻辑。那么我可以在哪里更改 wp_query 的自定义。以下是标准搜索。

$args = array('s'=> get_search_query(),
            'meta_key'  => 'edd_price',
            'order'     => 'ASC',
            'orderby'   => 'meta_value_num meta_value ',
            'post_type' => 'download',
            'posts_per_page'=>$posts_per_page_olam,
            'paged'     => $paged,
            'tax_query' => $taxQuery);

【问题讨论】:

  • 搜索功能有什么变化?

标签: wordpress search


【解决方案1】:

如果您想更改您网站上的搜索,请在搜索查询中hook,如下所示:

<?php add_action( 'pre_get_posts', 'func_53407889' );
function func_53407889( $query ) {
    if ( ! is_admin() && $query->is_main_query() && $query->is_search ) {
        // Change here whatever you want using the WP_Query's args
        // $query->set( 'post_type', 'event' );
    }
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-05-04
    • 1970-01-01
    • 2011-05-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-02-02
    相关资源
    最近更新 更多