Skip to content

Instantly share code, notes, and snippets.

@jonathan-bird
Last active December 21, 2015 11:58
Show Gist options
  • Save jonathan-bird/6302062 to your computer and use it in GitHub Desktop.
Save jonathan-bird/6302062 to your computer and use it in GitHub Desktop.
Wordpress: Use custom post type on home page
<?php
query_posts('post_type=featured-work');
if ( have_posts() ) : while ( have_posts() ) : the_post();
global $wpdb;
$metatable = $wpdb->prefix."postmeta";
$post_id = $post->ID;
$deschome = $wpdb->get_results($wpdb->prepare("SELECT meta_value FROM $metatable where post_id=%d AND meta_key='wpcf-featured-work-description-home'",$post_id));?>
<div class="work-home">
<div class="work-view">
<div class="work-img"><a title="<?php the_title(); ?>" href="<?php the_permalink() ?>"><?php the_post_thumbnail(); ?></a></div>
<div class="work-title"><a title="<?php the_title(); ?>" href="<?php the_permalink() ?>"><?php the_title(); ?></a></div>
<div class="work-desc"><a title="<?php the_title(); ?>" href="<?php the_permalink() ?>"><?php echo $deschome[0]->meta_value; ?></a></div>
</div>
</div>
<?php endwhile; endif;?>
<?php wp_reset_query(); ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment