我在那里遇到了一个非常大的问题。
我试图在WordPress上设计我的搜索结果页面,但是如果搜索找到包含我刚输入的关键字的页面,它会显示整个页面而不是标题();
我的代码
<?php
/**
* The template for displaying search results pages.
*
* @package miller
*/
get_header(); ?>
<section id="primary" class="content-area">
<main id="int_top_main" class="internal blue_top" style="min-height:80px;">
<div class="wrapper">
<h2 class="page_title uppercase"><span class="parent_page">Search results</h2>
<div id="infinite_blue_top_bar"></div>
</div>
</main><!-- #main -->
<div id="int_content_main" class="internal">
<div class="wrapper physician_headline">
<?php if ( have_posts() ) : ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php the_title(); ?>
<?php endwhile; ?>
<?php else : ?>
<h2><?php _e( 'Nothing Found', 'miller' ); ?></h2>
<div class="page-content">
<?php if ( is_search() ) : ?>
<p><?php _e( 'Sorry, but nothing matched your search terms. Please try again with some different keywords.', 'miller' ); ?></p>
<?php else : ?>
<p><?php _e( 'It seems we can’t find what you’re looking for. Perhaps searching can help.', 'miller' ); ?></p>
<?php endif; ?>
</div><!-- .page-content -->
<?php endif; ?>
</div>
</div>
</section><!-- #primary -->
<?php get_footer(); ?>
如果什么也没找到,它会进入其他地方:但是如果确实发现了什么,它们会显示它在那里找到的所有页面(整页)。
它应该只显示the_title();但没有..
即使我完全破坏了search.php文件,它仍然会自动转到&#34;建议&#34;页。
我第一次得到这种东西而且我不知道如何解决它:(
答案 0 :(得分:0)
它要求在标题之前发布帖子,这就是为什么它可以获得完整的帖子。
尝试:
<?php if ( have_posts() ) : ?>
<?php while ( have_posts() ) : the_title(); ?>
<?php endwhile; ?>
<?php else : ?>