Skip to content

Instantly share code, notes, and snippets.

@adrianosferreira
Last active December 18, 2015 16:10
Show Gist options
  • Save adrianosferreira/da3ff0c9f8365f91f252 to your computer and use it in GitHub Desktop.
Save adrianosferreira/da3ff0c9f8365f91f252 to your computer and use it in GitHub Desktop.
<?php
//Instanciando uma nova query sem parâmetros
$query = new WP_Query($args);

//Definindo o título que será base para o filtro
$titulo = "Meu Título";

$array = array();

//Um loop em todos os posts retornados pela query instanciada acima
foreach ($query->posts as $key => $value) {

    /*
     Se o post tiver o título que eu quero
     então eu incremento meu $array.
     Caso contrário, o post será removido dos
     resultados.
    */
	if( $value->post_title == $titulo ){

		$array[] = (array) $query->posts[$key];

	}else{

		unset($query->posts[$key]);
		
	}

}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment