Last active
October 6, 2018 11:06
-
-
Save qholzweg/8052500 to your computer and use it in GitHub Desktop.
Wordpress get_posts with thumb
This file contains hidden or 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 | |
$args = array('post_type' => array('page'), 'order' => 'ASC', 'orderby' => 'date'/* | |
to sort by custom fields | |
, 'meta_query' => array( | |
array( | |
'key' => 'meta', | |
'value' => true, | |
) | |
) | |
*/ | |
); | |
$myposts = get_posts( $args ); | |
foreach( $myposts as $post ) : setup_postdata($post); | |
?> | |
<div class="page"> | |
<?php | |
if ( has_post_thumbnail()) : | |
$full_image_url = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'full'); | |
$medium_image_url = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'mediunm'); | |
$small_image_url = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'thumbnail'); | |
?> | |
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><img src="<?= $full_image_url[0] ?>" /></a> | |
<?php endif; ?> | |
<h4><?php the_title(); ?></h4> | |
<p><?php the_excerpt(); ?></p> | |
</div> | |
<?php endforeach; ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks!
wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'full');
was I was looking for!