Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Wordpress 搜索结果的自定义布局_Wordpress - Fatal编程技术网

Wordpress 搜索结果的自定义布局

Wordpress 搜索结果的自定义布局,wordpress,Wordpress,在Wordpress 3.5.1中,我想创建并使用自定义布局来显示搜索结果。我在谷歌上搜索到了,但这并不是我想要的 好吧,我解决了我的问题,现在非常高兴:) 我在search.php文件中编写以下脚本 while ( have_posts() ) { the_post(); //get_template_part( 'content', get_post_format() ); $permali

在Wordpress 3.5.1中,我想创建并使用自定义布局来显示搜索结果。我在谷歌上搜索到了,但这并不是我想要的

好吧,我解决了我的问题,现在非常高兴:)

我在
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>';
            }
while(have_posts()){
_post();
//获取模板部分(“内容”,获取发布格式());
$permalink=get\u permalink($post->ID);
$title=获取标题($post->ID);
$feed=truncate(剥离标签(获取内容($post->ID)),0,300,“[…]”;
回声';
回声';
回声';
回显“”。
$feed
.'';
回声';
}