Display custom field values from posts on frontpage

How can I pull a custom field with meta_key “proprty_feature” (and has a value) for all posts and display them on my frontpage? Would like to display the post name as a link above the value..

Related posts

Leave a Reply

1 comment

  1. Within your main post loop you would add something like,

    get_post_meta($post->ID, 'property_feature', true);
    

    A basic example of what your main loop might look like ( it depends on your theme) to include a title and your custom field.

    //start the loop
    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    
    //add post link and title
    <a href="<?php the_permalink() ?>" rel="bookmark" title="Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a>
    
    //add your custom meta value
    <?php echo get_post_meta($post->ID, 'property_feature', true) ?>
    
    //close loop
    <?php endwhile; else: ?>