Skip to content

Instantly share code, notes, and snippets.

@richlloydmiles
Last active August 29, 2015 14:06
Show Gist options
  • Save richlloydmiles/c5a41be4c152a0cf5370 to your computer and use it in GitHub Desktop.
Save richlloydmiles/c5a41be4c152a0cf5370 to your computer and use it in GitHub Desktop.
Custom wordpress query
<?php
$post_args = array(
'post_type' => 'video',
'post_status' => 'publish',
'posts_per_page' => '0',
'meta_key' => 'bs_video_featured',
'meta_value' => 1
);
$post = new WP_Query( $post_args );
if($post->have_posts()){
while($post->have_posts()){ $post->the_post();
$url;
if ( has_post_thumbnail() ) {
$thumb = wp_get_attachment_image_src( get_post_thumbnail_id(), 'large');
$url = $thumb['0'];
} else {
$url = 'http://placehold.it/287x168/';
}
echo $url;
}
}
wp_reset_query();
?>
@richlloydmiles
Copy link
Author

This is a gist that makes a database connection and then pulls in the featured image's url.

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