Skip to content

Instantly share code, notes, and snippets.

@Dianakc
Last active September 10, 2015 15:36
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 Dianakc/9299136 to your computer and use it in GitHub Desktop.
Save Dianakc/9299136 to your computer and use it in GitHub Desktop.
Obter o ID (qualquer campo) de um único post
<?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