Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

Alex_182721

Mecanismo de busca WP

Recommended Posts

Galera, segue mais um caso do bendito PHP.

 

Estou com um template no Wordpress que tem um mecanismo de busca que age da seguinte forma, quando fazemos alguma busca:

 

Encontra Título + um resumo da postagem.

 

O que eu queria é que a busca fosse somente pelo título (pois ela busca palavras dentro do texto da postagem) e que mostrasse também uma imagem da postagem, portanto é só uma questão de reconfiguração.

 

Segues os códigos:

 

searchform.php: (formulário da pesquisa)

 

 

<ul>

<!-- <div align="center"> -->

<form method="get" id="searchform" action="<?php bloginfo('home'); ?>/">

<!-- <input type="text" value="<?php the_search_query(); ?>" name="s" id="s" size="20" /> -->

<input type="text" style="background: #fff; border: 1px #000 solid;" value="<?php _e('Pesquisa','emerald_stretch'); ?>" name="s" id="s" size="20" onfocus="if (this.value == '<?php _e('Pesquisa','emerald_stretch'); ?>') {this.value = '';}" onblur="if (this.value == '') {this.value = '<?php _e('Pesquisa','emerald_stretch'); ?>';}" />

<input type="submit" style="background: #000080; color: #fff; border: 1px #DCDCDC solid;" id="searchsubmit" value="<?php _e('Pesquisar','emerald_stretch'); ?>" />

</form>

<!-- </div> -->

</ul>

 

---------------------------------

 

SEARCH.PHP (resultados da pesquisa)

 

<?php get_header(); ?>

 

<!-- CONTENT -->

 

<div id="content-wrapper">

<div id="content">

 

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

 

<h1 class="pagetitle"><img border="0" height="25" src="http://www.buscola.com.br/classificados/imagens/ampliar_fotos.png" style="border: none;" width="30" /><span style="color: #666;">Pesquisa pela palavra</span> <?php /* Search Count */ $allsearch = &new WP_Query("s=$s&showposts=-1"); $key = wp_specialchars($s, 1); $count = $allsearch->post_count; _e(''); _e('<span class="search-terms">'); echo $key; _e('</span>'); _e(': '); echo $count . ' '; _e('<span style="color: #666;">resultado (s) encontrado (s)</span>'); wp_reset_query(); ?></h1>

 

<?php while (have_posts()) : the_post(); ?>

 

<h1 id="post-<?php the_ID(); ?>"><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php _e('Permanent Link to ','emerald_stretch'); ?><?php the_title(); ?>"><?php the_title(); ?></a></h1>

<?php the_excerpt(); ?>

 

<p id="postmeta">

<img src="<?php bloginfo('template_directory'); ?>/img/calendar.gif" /><a href="<?php bloginfo('url'); ?>/<?php the_time('Y') ?>/<?php the_time('m') ?>/" title="<?php _e('View all posts for the month of','emerald_stretch'); ?> <?php the_time(__('F, Y','emerald_stretch')) ?>"><?php the_time(__('F j, Y','emerald_stretch')) ?></a>

· <img src="<?php bloginfo('template_directory'); ?>/img/card.gif" /><?php // echo " "; _e('by','emerald_stretch'); ?><?php the_author_link(); ?>

· <img src="<?php bloginfo('template_directory'); ?>/img/comments.gif" /><?php comments_popup_link(__('Sem perguntas','emerald_stretch'), __('One Comment','emerald_stretch'), __('% Comments','emerald_stretch'), '', __('Nesta página não é permitido escrever', 'emerald_stretch')); ?>

<br />

<img src="<?php bloginfo('template_directory'); ?>/img/tag.gif" /><?php the_tags(__('Tags','emerald_stretch') . ': ', ', ', ' · '); ?><?php _e('Categoria', 'emerald_stretch'); ?>: <?php the_category(', ') ?>

<span class="editlink"><?php edit_post_link(__('Edit','emerald_stretch'),'',''); ?></span>

</p>

 

<?php endwhile; ?>

 

<br />

<ul class="postnav">

<li class="left"><?php next_posts_link(__('« Older Entries','emerald_stretch')) ?></li>

<li class="right"><?php previous_posts_link(__('Newer Entries »','emerald_stretch')) ?></li>

</ul>

 

<?php else : ?>

 

<h1 class="pagetitle"><?php _e('Não há anúncios para sua pesquisa.','emerald_stretch'); ?></h1>

<p><?php _e('<b>DICA:</b>','emerald_stretch'); ?></p>

<p><?php _e('Verifique se há erros na palavra pesquisada;','emerald_stretch'); ?></p>

<p><?php _e('Busque por palavras específicas;','emerald_stretch'); ?></p>

<p><?php _e('Você pode navegar por <a href="#">todas as categorias</a>, assim será mais fácil encontrar o que procura.','emerald_stretch'); ?></p>

 

<?php endif; ?>

 

</div>

<!-- /CONTENT -->

<?php get_sidebar(); ?>

<?php get_footer(); ?>

 

------------------

 

Valeu galera, desde já agradeço pela ajuda.

Compartilhar este post


Link para o post
Compartilhar em outros sites

acredito q seja aki: &new WP_Query("s=$s&showposts=-1");

 

troque

 

&new WP_Query("s=$s&showposts=-1");

 

por

 

&new WP_Query("s=$s");

 

e veja no q da..

 

Fiz o que você falou, mas não deu certo... por que será?

 

Preciso muito resolver isso =[

 

 

O que podemos tentar agora?

 

Valeu pela ajuda.

 

Alguém pode me ajudar, pessoal?

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.