0
由于某种原因,网站搜索正确显示结果的链接被破坏。WordPress的搜索结果显示结果是断开的链接
例
<a href="http://example.com/health-safety/">Health Safety</a>
这是我从搜索结果中获得。事实上,该链接应该已经转到下一页。
http://example.com/careers/working-for-us/
从管理员,我已经在类别的帖子下输入此信息。
这里的PHP代码(我觉得没有什么是错的PHP代码)
<?php if (have_posts()) : ?>
<ul class="searchul table-striped">
<?php while (have_posts()) : the_post(); ?>
<li>
<h4 ><a href="<?php permalink_link();?>"><?php the_title(); ?></a></h4>
<?php the_excerpt();?>
</li>
<?php endwhile; ?>
</ul>
<div class="search-results-paginglinks"><?php posts_nav_link(); ?></div>
<?php else : ?>
<div class="search_result_error" style="margin-top: 25px;"><?php _e('Sorry, Your search did not match any criteria.'); ?></div>
<?php endif; ?>
更多信息 我试图将此代码添加到functions.php中。这样做只是查询和搜索页面而不是帖子。我需要所有的网页和帖子
/* Search */
function SearchFilter($query) {
if ($query->is_search) {
$query->set('post_type', 'pages');
}
return $query;
}
add_filter('pre_get_posts','SearchFilter');