Wordpress: loop through post with custom field -


i loop through posts , category_name=news, how can display each post's custom field? thank in advance.

<?php $prenewsposts = new wp_query(); $prenewsposts->query('posts_per_page=3&category_name=news'); while($prenewsposts->have_posts()): $prenewsposts->the_post(); ?> <a href="<?php the_permalink(); ?>" class="atitle" ><?php the_post_thumbnail('thumbnail'); ?><?php the_title(); ?></a> <?php the_excerpt(); ?> <hr style="width: 95%; border: 1px solid #e6e6e6; " /> <?php endwhile; ?> 

this should work, place inside while loop. make sure change custom_field name of custom field

echo get_post_meta($prenewsposts->post->id, 'custom_field', true); 

Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -