2
I created the files search.php
and searchform.php
for a Wordpress theme that I am developing. However when testing the search it does not return anything, showing only the home page.
I had written a different pattern query in another theme of an old project and in this theme it works normally, but in my current project this error occurs. The codes are as follows::
searchform.php
<form action="<?php bloginfo('home'); ?>" method="get" accept-charset="utf-8" id="searchform" role="search">
<input type="text" id="campo_busca" name="busca" placeholder="Buscar" value="<?php the_search_query(); ?>"></input>
<input id="button_busca" type="submit"></input>
</form>
search php.
<?php
/*
Template Name: Search Page
*/
?>
<?php get_header(); ?>
<main>
<div class="content">
<section id="conteudo_pagina">
<p id="tempobusca"><?php $mySearch = & new WP_Query("s=$s & showposts=20"); $num = $mySearch->post_count; echo $num.' resultados de pesquisa para '; the_search_query();?> em <?php get_num_queries(); ?> <?php timer_stop(1); ?> segundos.</p>
<?php if ( have_posts() ) : ?>
<?php while ( have_posts() ) : the_post(); ?>
<div class="box internas">
<div class="cabecalho">
<h2>BUSCA</h2>
</div>
</div>
<ul id="linha_pesquisa">
<li>
<article>
<p class="titulobusca"><a href="<?php the_permalink() ?>" rel="bookmark" title="Link permanente para <?php the_title(); ?>"><?php the_title(); ?></a></p>
<p class="excertobusca"><?php the_content_rss('more_link_text', TRUE, '', 30); ?></p>
</article>
</li>
</ul>
<?php endwhile; ?>
<div id="paginacao">
<?php if(function_exists('wp_pagenavi')) : ?>
<?php wp_pagenavi() ?>
<?php else : ?>
<div class="maisantigos"><?php next_posts_link(__('« Mais antigos','arclite')) ?></div>
<div class="maisrecentes"><?php previous_posts_link(__('Mais recentes »','arclite')) ?></div>
<?php endif; ?>
</div>
<?php else:?>
<ul id="linha_pesquisa">
<li>
<article>
<h3>404 - NOT FOUND</h3>
<h4>Post não encontrado</h4>
<p>Desculpe, mas o texto que você procura não está aqui.</p>
</article>
</li>
</ul>
<?php endif; ?>
</section>
<?php get_sidebar(); ?>
<?php get_footer(); ?>
How can I solve this problem?
Thank you very much! I made the corrections and the search came back to work.
– Giancarlo Silva