Last active
August 29, 2015 14:06
-
-
Save richlloydmiles/c5a41be4c152a0cf5370 to your computer and use it in GitHub Desktop.
Custom wordpress query
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 | |
$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(); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is a gist that makes a database connection and then pulls in the featured image's url.