• Josh Ford

    (@joshford1maccom)


    I’m using this on my home page to display a featured post

    <?php $posts = get_posts( array( 'category' => 23 ) ); ?>
    	    <?php foreach ($posts as $post): ?>
    	        <li>
    	            <a href="<?php echo get_page_link( $post->ID ); ?>" >
    			<h1>Featured Post</h1>
    			<?php echo get_the_post_thumbnail($post->ID); ?>
    			<ul>
    				<li><?php echo $post->post_title; ?></li>
    				<li><?php echo $post->post_excerpt; ?></li>
    			</ul>
    		    </a>
    	        </li>
    	    <?php endforeach; ?>

    It works as required but I need to also display in the list the key and value from 2 custom fields for that post and can’t figure it out. Searched the codex and forums but getting confused as per the correct syntax. Any help greatly appreciated.

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘get-posts – how to get custom fields data’ is closed to new replies.