Why doesn't get_post_custom() work within the loop in WordPress? -


i've created custom post type in wordpress, , in single post template, i'm pulling in custom data using get_post_custom() function.

but inside loop on list of posts, function doesn't work , comes empty array.

here's have:

<?php $loop = new wp_query( array( 'post_type' => 'web-design', 'posts_per_page' => 10 ) ); ?>  <?php $i = 0; ?>  <?php while ( $loop->have_posts() && $i < 3 ) { $loop->the_post(); ?>  <article class="project-link <?php echo 'num' . $i ?>">     <div class="pad">          <?php $project_info =  get_post_custom(); ?>          <?php           foreach ($project_info $i => $values) {             print "$i {\n";             foreach ($values $key => $value) {                 print "$key => $value\n";             }             print "}\n";         }          ?>                <?php echo $project_info['url'][0]; ?>   

and don't have coming @ all.

does know why doesn't work? works fine in single post template, why not in loop?

thanks!

the post_custom() has many variables stored in arrays ..

if know specific key , or value need can use

or itirate through them :

<?php    $mykey_values = get_post_custom_values('my_key');   foreach ( $mykey_values $key => $value ) {     echo "$key  => $value ('my_key')<br />";    }  ?> 

or specific post

<?php    $custom_fields = get_post_custom(72);   $my_custom_field = $custom_fields['my_custom_field'];   foreach ( $my_custom_field $key => $value )     echo $key . " => " . $value . "<br />";  ?> 

Comments

Popular posts from this blog

jasper reports - Fixed header in Excel using JasperReports -

media player - Android: mediaplayer went away with unhandled events -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -