views:

50

answers:

1

i'm trying to create a portfolio website using wordpress,

each post has view costum fields, one of which is called type - with the value of "featured" or "not-featured"

now when user clicks on the post title - they go the the single.php to see the entire post, here i would love to display all featured thumbnails

i tried this

         <?php while ( have_posts() ) : the_post() ?>

      <?php  if(get_post_meta($post->ID, 'type', true) == "featured") {; ?>
  <h2 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php printf( __('Permalink to %s', 'your-theme'), the_title_attribute('echo=0') ); ?>" rel="bookmark"> 
<img src="<?php echo get_post_meta($post->ID, 'intro_thump', true); ?>" alt="Icon for Post #<?php the_ID(); ?>" />
</a></h2>
<?php  }; ?>
<div class="entry-content">

     </div><!– .entry-content –> 
      <?php endwhile; ?> 

(THIS CODE IS SIMILAR TO THE CODE I USE AT INDEX.PHP AND THERE IT DOES WORK, HERE AT SINGLE.PHP IT DOES NOT WORK)

but this does not display all the thumbnails (only the current posts' thumbnail (is it's a feature post))

this is my first attempt of trying to create a theme from blank so i'm not sure what the error could be

thanks for your help

+1  A: 

The code in your question only loops through the posts returned by the query made for the current view, in the case of a single post view that is one post. You want to perform a new query to retrieve all the posts that have the required meta value:

<?php
  query_posts(array("meta_key" => "type", "meta_value" => "featured"));
  if (have_posts()) : while (have_posts()) : the_post();
?>
  <!-- Display thumbnails -->
<?php endwhile; endif; ?>
Richard M
it could be my lack of explenation but your code is not giving me any result (including the thumbnail section)whereas i just found that if i add this line of code <?php query_posts('showposts=100'); ?>on top of my code (above) it gives me what i needbut from looking at your code i have a feeling mines is wrong (with unnecessary code)thanks anyway
aurel
hey, i'm sorry, your code does work - i had made a mistake (for some reason i changed the value "featured" to "feature")it shows the level of "expertize" i have in this fieldthanks very much
aurel