wordpress - 搜索结果的自定义布局

标签 wordpress

在 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">&nbsp;</div>'.
                        $feed
                        .'</div>';

                echo '</div>';
            }

关于wordpress - 搜索结果的自定义布局,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17841403/

相关文章:

html - 文件已删除但仍在显示

php - 让信息窗口在循环中工作

php - 我需要代码让 Wordpress 显示 5 列帖子

wordpress - 谁能发现我的Wordpress循环为何中断其后的所有“高级自定义字段”代码?

php - 在最近帖子的标题旁边显示帖子格式图标

php - 使用 jQuery 将背景图像 css 设置为 wordpress 中的特色图像

wordpress - 如何以编程方式显示我的 wordpress 小部件?

php - 无法将下载的 HTML 模板集成到 wordpress 主题中

javascript - 当您滚动到页面底部时,如何打开一个新页面,就像单击链接一样

html - 在 Wordpress 中的每篇文章后添加分隔符