Skip to content

Instantly share code, notes, and snippets.

@taniarascia
Created September 1, 2015 22:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save taniarascia/055e2d3bc4438b561378 to your computer and use it in GitHub Desktop.
Save taniarascia/055e2d3bc4438b561378 to your computer and use it in GitHub Desktop.
Correct Way to Pull From a Custom Loop
<?php get_header(); ?>
<?php $featured_image = wp_get_attachment_url(get_post_thumbnail_id($page->ID));
if (have_posts()) : while (have_posts()) : the_post();
?>
<div class="container" id="services_container">
<img src="<?php echo $featured_image;?>" class="left_image">
<div class="left_box">
<h2><?php the_title();?></h2>
<p>
<?php the_content();?>
</p>
<?php endwhile; endif;?>
<ul>
<?php
$new = new WP_Query('post_type=services-custom&orderby=menu_order&order=ASC');
while ($new->have_posts()) : $new->the_post();
$meta = get_post_meta($post->ID,'_my_meta',TRUE);
?>
<li>
<a href="<?php echo $meta['pdf'];?>" target="_blank">
<?php the_title();?>
</a>
</li>
<?php endwhile; ?>
</ul>
</div>
<div style="clear: both"></div>
</div>
<?php get_footer(); ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment