Created
September 2, 2012 18:08
-
-
Save krusynth/3602435 to your computer and use it in GitHub Desktop.
Wordpress: Featured posts to frontpage
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
<ul class="gallery-list"> | |
<?php /* Featured galleries */ | |
$parent_id = $post->ID; | |
$featured_args = array( | |
'post_type' => 'page', | |
'meta_key' => 'featured', | |
'meta_value' => 1, | |
'posts_per_page' => -1, | |
'post_parent' => $parent_id, | |
'orderby' => 'menu_order', | |
'order' => 'ASC' | |
); | |
$featured_query = new WP_Query($featured_args); | |
?> | |
<?php if ( $featured_query->have_posts() ) : while ( $featured_query->have_posts() ) : $featured_query->the_post(); | |
$title = $post->post_title; | |
$featured_image_id = get_post_meta( $post->ID, '_thumbnail_id', true ); | |
if($featured_image_id) { | |
$featured_image = wp_get_attachment_image_src( $featured_image_id, "full", false, $attr ); | |
} | |
if($featured_image) : | |
$attachment_link = get_permalink($post->ID); | |
?> | |
<li><a title="<?php print $title ?>" href="<?php print $attachment_link ?>"><img alt="<?php print $title ?>" src="<?php print $featured_image[0] ?>" /></a></li> | |
<?php endif; /* $featured_image */ ?> | |
<?php endwhile; else: /* if !have_posts() */ ?> | |
<?php endif; /* if have_posts() */ ?> | |
</ul> | |
<?php wp_reset_postdata(); ?> | |
<?php wp_reset_query(); ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment