Skip to content

Instantly share code, notes, and snippets.

@henryhu712
Last active March 23, 2016 05:22
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 henryhu712/1edcb659cc9818ed7a94 to your computer and use it in GitHub Desktop.
Save henryhu712/1edcb659cc9818ed7a94 to your computer and use it in GitHub Desktop.
Wordpress - Get all posts of a custom type 'campaign' #wordpress
$loop = new WP_Query( array(
'post_type' => 'campaign',
'posts_per_page' => -1, // It will return all posts.
));
while ( $loop->have_posts() ) {
$loop->the_post();
$post_id = get_the_ID();
$post_title = get_the_title();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment