首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Wordpress:在表格中搜索项目

Wordpress:在表格中搜索项目
EN

Stack Overflow用户
提问于 2015-04-25 01:51:55
回答 1查看 86关注 0票数 5

我已经创建了一个测试页面,其中用户可以访问pdf和word文档。

网址:http://recordandreturn2.insctest1.com/online-forms

wordpress网站上的默认搜索功能不会在您键入任何项目后调出任何项目。例如,搜索“继承权宣誓书”。我使用了一个叫做easy table的插件,因为客户端将需要轻松地添加或删除向前移动的项目。我已经搜索了wordpress搜索功能的增强器,但似乎都不起作用。

这个示例站点有一个显示表单的搜索特性,这就是我想要实现的:http://www.judicialtitle.com/resources/forms

EN

回答 1

Stack Overflow用户

发布于 2015-04-25 02:25:28

这是一个能够搜索快捷码的插件:https://wordpress.org/plugins/wp-ultimate-search/

或者,您可以将以下内容添加到functions.php中,以便在搜索中包含快捷方式代码

代码语言:javascript
复制
<?php
//Replace wp_trim_excerpt with a commented out strip_shortcodes()
function improved_trim_excerpt($text) {
    $raw_excerpt = $text;
    if ( '' == $text ) {
        $text = get_the_content('');

        //$text = strip_shortcodes( $text );

        $text = apply_filters('the_content', $text);
        $text = str_replace(']]>', ']]>', $text);
        $text = strip_tags($text);
        $excerpt_length = apply_filters('excerpt_length', 55);
        $excerpt_more = apply_filters('excerpt_more', ' ' . '[...]');
        $words = preg_split("/[\n\r\t ]+/", $text, $excerpt_length + 1, PREG_SPLIT_NO_EMPTY);
        if ( count($words) > $excerpt_length ) {
            array_pop($words);
            $text = implode(' ', $words);
            $text = $text . $excerpt_more;
        } else {
            $text = implode(' ', $words);
        }
    }
    return apply_filters('improved_trim_excerpt', $text, $raw_excerpt);
}

remove_filter('get_the_excerpt', 'wp_trim_excerpt');
add_filter('get_the_excerpt', 'improved_trim_excerpt');

//You might also need to add this in order to make sure the 
//shortcodes are actually parsed and not just displayed
//$text = do_shortcode($text);
?>

这段代码来自http://3rdplanetwebsolutions.com/news/add-shortcode-content-to-wordpress-search-results/

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/29854270

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档