Last active
September 10, 2015 15:36
-
-
Save Dianakc/9299136 to your computer and use it in GitHub Desktop.
Obter o ID (qualquer campo) de um único post
This file contains 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 | |
$myposts = get_posts('category_name=carros&posts_per_page=1'); //exemplo de um post da categoria "Carros" | |
$r = wp_list_pluck( $myposts, 'ID' ); //no caso ID, pode ser outros campos | |
echo 'O ID do post:'.$r[0]; //usar [0] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment