Skip to content

Instantly share code, notes, and snippets.

@lucianobragaweb
Last active May 19, 2018 20:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lucianobragaweb/7227544 to your computer and use it in GitHub Desktop.
Save lucianobragaweb/7227544 to your computer and use it in GitHub Desktop.
Remover páginas da busca Wordpress
<?php get_header(); // header do site ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); // while retorna os posts existentes de acordo com o critério de busca fornecido pelo usuário
// agora vem a mágica para fazer com que não sejam exibidas as páginas na listagem dos posts retornados pela busca
if($post->post_type == 'page') continue; // esta condição if faz com que quando o post for do tipo 'page', ele simplesmente pula este conteúdo.
?>
<!-- Aqui vem a listagem dos posts da forma como achar mais conveniente -->
<?php endwhile; endif; // fecha while. ?>
<?php get_footer(); // Footer do site ?>
<!-- Veja mais detalhes aqui: https://lucianobragaweb.github.io/post/remover-pagina-da-busca-wordpress/ -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment