Skip to content

Instantly share code, notes, and snippets.

@musicalbigfoot
Created March 24, 2015 17:16
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 musicalbigfoot/e3fbc3a211da6ae5365c to your computer and use it in GitHub Desktop.
Save musicalbigfoot/e3fbc3a211da6ae5365c to your computer and use it in GitHub Desktop.
WordPress: Custom Post Type Query
<?php
$__POST_display = array();
$args = array(
'post_type' => '__POST',
'posts_per_page' => -1,
);
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
$image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full' );
if (isset($image[0]) && $image[0] != "") {
$__POST_display[] = array(
'title' => get_the_title(),
'content' => wpautop(do_shortcode(get_the_content())),
'image' => $image[0],
);
}
endwhile;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment