我有一个searchform.php和一个search.php在search.php文件下我有以下代码:
<?php if (have_posts()) : ?>
<?php
while (have_posts()) : the_post(); ?>
<div class="row">
<div class="col-md-12">
<h1><a href="<?php echo get_post_meta($post->ID, 'linkcautare', true); ?>"> <?php the_title();?> </a></h1>
</div>
</div>
<div class="row">
<div class="col-md-12">
<p><?php the_excerpt(); ?></p>
</div>
</div>
<?php endwhile;
else :
echo '<p>No content found!</p>';
endif; ?>
</div>
</div>
问题是我如何通过在顶部播种最多的帖子来列出帖子?
add_filter('posts_orderby','my_sort_custom',10,2);
function my_sort_custom( $orderby, $query ){
global $wpdb;
if(!is_admin() && is_search())
$orderby = $wpdb->prefix."posts.post_type DESC, {$wpdb->prefix}posts.post_date DESC";
return $orderby;
}
这是我的方式改变后类型&填迟日期
更改查询如果你有页面浏览量