在 WordPress 3.5.1 中,我想创建并使用自定义布局来显示搜索结果。我用谷歌搜索发现http://codex.wordpress.org/Creating_a_Search_Page但这不正是我想要的。
最佳答案
好吧,我解决了我的问题,现在很高兴:)
我在 search.php
文件中编写以下脚本
while ( have_posts() ) {
the_post();
//get_template_part( 'content', get_post_format() );
$permalink = get_permalink($post->ID);
$title = get_the_title($post->ID);
$feed = truncate( strip_tags( get_the_content($post->ID) ), 0, 300, "[...]");
echo '<div class="posts">';
echo '<div style="float:left">';
echo '<a class="featured-img">
'.the_post_thumbnail('thumbnail').'
</a>';
echo '</div>';
echo '<div class="posts-content">';
echo '<div class="heading"><a href="'.$permalink.'">'.$title.'</a></div>';
echo '<div class="comments"> </div>'.
$feed
.'</div>';
echo '</div>';
}
关于wordpress - 搜索结果的自定义布局,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17841403/