Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/275.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
Php wordpress自定义主题搜索具有数量,但不显示结果_Php_Wordpress_Search - Fatal编程技术网

Php wordpress自定义主题搜索具有数量,但不显示结果

Php wordpress自定义主题搜索具有数量,但不显示结果,php,wordpress,search,Php,Wordpress,Search,尽我最大的努力去了解wordpress的搜索过程和结果。 在这个阶段,我已经连续8个小时在网上阅读和研究,但几乎一无所获 我有一个完全定制的主题,由一位朋友为客户设计。我在页面顶部的导航栏中有一个搜索框,在页眉内。我希望用户能够在任何时候从导航栏的搜索框中搜索网站的内容。我在其他页面上发现了很多这样的例子,尽管它们似乎经常使用现成的主题 最终,我希望能够很好地理解search.php文件中的内容,以便将其与searchform.php文件一起编辑,从而使搜索框和结果与主题的其余部分统一起来 目前

尽我最大的努力去了解wordpress的搜索过程和结果。 在这个阶段,我已经连续8个小时在网上阅读和研究,但几乎一无所获

我有一个完全定制的主题,由一位朋友为客户设计。我在页面顶部的导航栏中有一个搜索框,在页眉内。我希望用户能够在任何时候从导航栏的搜索框中搜索网站的内容。我在其他页面上发现了很多这样的例子,尽管它们似乎经常使用现成的主题

最终,我希望能够很好地理解search.php文件中的内容,以便将其与searchform.php文件一起编辑,从而使搜索框和结果与主题的其余部分统一起来

目前,我能做的最接近于让任何东西发挥作用的是包含大量的搜索结果,显示预期的适当点击数,但我仍然不知道如何显示结果

我一直在搜索其他人的页面资源,以及谷歌搜索到的每一个关于自定义或解释search.php文件的信息,但我一直在寻找的都是创建搜索页面,这一定是一个主题问题。这不是有收益的信息

我对创建搜索页面信息的理解是,它描述了创建自定义搜索页面的步骤,用户可以超链接/永久链接到该页面,但与wordpress工具包中的默认搜索功能无关。事实上,我已经成功创建了一个自定义搜索页面,但它的行为只是作为一个独立页面,与自定义搜索结果页面无关。要自定义默认搜索函数结果的外观,我知道search.php文件必须经过编辑。到目前为止,我还不知道该在该文件中编辑什么,但现在我只想理解为什么我看到了正确数量的结果,但没有实际结果

我的search.php文件如下所示:

<?php get_header(); ?>

THIS IS THE TOP OF SEARCH.PHP

    <section id="primary" class="content-area">
        <div id="content" class="site-content" role="main">

            <?php if ( have_posts() ) : ?>

            <header class="page-header">
                <h1 class="search-title">
                    <?php echo $wp_query->found_posts; ?> <?php _e( 'Search Results Found For', 'locale' ); ?>: "<?php the_search_query(); ?>"
                </h1>
            </header><!-- .page-header -->

                <?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.
                    twentyfourteen_paging_nav();*/

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

                endif;
            ?>

        </div><!-- #content -->
    </section><!-- #primary -->

THIS IS AFTER THE SECTION OF SEARCH.PHP

<?php
// get_sidebar( 'content' );
// get_sidebar();
get_footer();
<form role="search" method="get" class="search-form" action="<?php echo home_url( '/' ); ?>">
    <label>
        <input type="search" class="search-field" placeholder="search …" value="" name="s" title="Search for:" />
    </label>
    <input type="submit" class="search-submit" value="Search" />
</form>
我已经读了很多遍了《创建搜索页面》,我可能会背诵一遍,但没有找到任何解决方案

我已经阅读了stackoverflow的相关文章,并尝试了来自Meshaper的代码,但这在shape\u content\u导航行上引发了一个错误

我读过并且。。。显然,我无法链接到我读过的所有其他内容,因为这是我的第一篇文章,但我读了很多,而且做了很多修改,进展甚微


为冗长的帖子道歉。只是想彻底展示我的研究成果和当前的理解点。

如果你把

大学名称

直接在你的while声明之后

每次在while循环中循环时,您都在处理每个帖子。目前,在每个循环中,您都要输入一个content-*.php文件,其中*取决于post格式。那个文件存在吗