首页 文章

在Wordpress中编辑搜索结果模板

提问于
浏览
1

我使用可爱的自定义字段插件创建了一个具有漂亮布局的页面模板,因此我的客户端可以轻松更新内容 .

我在该页面模板上创建了一个循环,可以很好地显示相关信息;

这是我制作的循环:

<?php
    $args = array( 'post_type' => 'cripps_staff', 'posts_per_page' => 300 );
    $loop = new WP_Query( $args );
    while ( $loop->have_posts() ) : $loop->the_post();

    echo '<div class="col-md-3 spacetop">';
    echo '<a href="'.get_permalink().'">';
    echo get_post_meta($post->ID,'image',true);
    echo '</a>';
    echo '<h2 class="staffname">';
    echo get_post_meta($post->ID,'staff_name',true);
    echo '</h2>';
    echo '<h2 class="staffrole">';
    echo get_post_meta($post->ID,'staff_role',true);
    echo '</h2>';
    echo '<h2 class="staffnumber">';
    echo get_post_meta($post->ID,'staff_telephone_number',true);
    echo '</h2>';
    echo '<h2 class="staffemail">';
    echo get_post_meta($post->ID,'staff_email_address',true);
    echo '</h2>';
    echo '</div>';
    endwhile;
    ?>

我创建了分类法,因此工作人员分为几类 .

然后我使用一个名为Taxonomies过滤器的插件来创建您将看到的下拉选项 . 当您在下拉列表中选择一个元素时,Wordpress会转到/将页面更改为我创建的自定义搜索结果页面 . 我希望我的搜索结果与人物模板上的循环完全一样 . 目前它只是在h1标签中吐出 Headers .

这是我从Twenty Fourteen主题获得的代码:

<?php
                // Start the Loop.
                while ( have_posts() ) : the_post();

                    /*
                     * Include the post format-specific template for the content. If you want to
                     * use this in a child theme, then include a file called called content-___.php
                     * (where ___ is the post format) and that will be used instead.
                     */
                    get_template_part( 'content', get_post_format() );

                endwhile;
                // Previous/next post navigation.
                CrippsTheme_paging_nav();

            else :
                // If no content, include the "No posts found" template.
                get_template_part( 'content', 'none' );

            endif;
        ?>

如何让搜索结果看起来与我的Post循环完全一样?

1 回答

相关问题