This is going to sound a little nuts. I have a situation where I'm displaying a list of products that a user selects to move to the products' page. I also have documents and videos that I created custom post types and fields for. I need to run a second loop within the current loop to pull a custom field from a custom post type. If that makes sense?
for example this is the product "directory" loop (pardon my hackish techniques)
<div id="content" role="main">
<?php
$parent = $post->ID;
query_posts('post_type=page&order=ASC&orderby=title&post_parent='.$parent);?>
<?php while (have_posts()) : the_post(); ?>
<?php $model = get_the_title(); ?>
<div class="product-selection-container round">
<h2 class="directory-title"><a href="<?php the_permalink() ?>"><?php echo get_post_meta($post->ID, "product-main-title", true); ?></a></h2>
<h3>Model <?php echo $model ?></h3><!-- the model -->
<?php echo my_excerpts(); ?>
<ul class="round">
<li><a href="<?php the_permalink() ?>">Learn More</a></li>
<li><a href="">Specification Sheet</a></li>
<li><a href="">Video Tour</a></li>
</ul>
</div>
</div>
<?php endwhile; ?>
And this is the loop I generally use to add documents to the pages (excluding the custom loop template)
<?php
$documents = array('numberposts' => 5, 'post_type' => 'documents', 'category_name' => $model);
query_posts( $documents );
get_template_part( 'loop', 'documents' );
wp_reset_query();
?>
I tried combining the two where I would add the second loop to <li><a href="">Specification Sheet</a></li> but that caused the page to run in a perpetual loop.
An alternative option I was looking for was to pull a single custom field from a post type without creating a loop. For example.
get post_type => document, meta_key => document-type, meta_value => spec-sheet
Any help would be appreciated.