我创建了一个测试页面,用户可以在其中访问pdf和word文档。
网站:http://recordandreturn2.insctest1.com/online-forms
wordpress网站上的默认搜索功能在您输入后不会显示任何项目。例如,搜索“Heirship的宣誓书”。我正在使用一个名为easy table的插件,因为客户端需要轻松添加或删除前进的项目。我搜索过wordpress搜索功能增强器,但似乎没什么用。
此示例网站有一个搜索功能,可以显示表单,这是我想要实现的目标:http://www.judicialtitle.com/resources/forms
答案 0 :(得分:1)
这是一个能够搜索短代码的插件: https://wordpress.org/plugins/wp-ultimate-search/
或者,您可以将以下内容添加到functions.php中,以在搜索中包含短代码
<?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/