Last active
December 10, 2015 20:28
-
-
Save claudiosanches/4488596 to your computer and use it in GitHub Desktop.
Excluir categorias da homepage.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Excluir categorias da homepage. | |
* | |
* @param object $query Query padrão. | |
* | |
* @return object Query sem algumas categorias. | |
*/ | |
function cs_homepage_loop( $query ) { | |
// Funciona apenas na home. | |
if ( is_home() || is_home() && is_paged() ) { | |
// Aqui você deve determinar o ID da categoria ou categorias que você quer excluir. | |
// Elas precisam ter o sinal de menos (-) e o ID | |
// Exemplo de como excluir mais de uma categoria: '-3, -5, -9' | |
$query->set( 'cat', '-24' ); | |
return; | |
} | |
} | |
add_filter( 'pre_get_posts', 'cs_homepage_loop' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment