WordPress.org

Ready to get started?Download WordPress

Forums

dislpaying featured posts with title in header (1 post)

  1. anuragupadhaya
    Member
    Posted 5 years ago #

    NOTE: i didn't find any satisfactory link for this thing on web.
    i am trying to include header of sites like wired.com or lifehacker.com, but with a minimal theme in my blog.
    But i didn't find any satisfactory code on internet. Any designer would help me anyhow??

    I am trying to include featured posts with titles in the header of my theme.

    this is the code:

    <div id="featured">
    	<ul id="carousel">
    		<?php
    		$featured_posts = get_posts('numberposts=3&amp;category=1');
    
    		foreach( $featured_posts as $post ) {
    			$custom_image = get_post_custom_values('featured_image', $post->ID);
    			$image = $custom_image[0] ? $custom_image[0] : get_bloginfo("template_directory")."/images/no-featured-image.jpg";
    			printf('<li><a href="%s" title="%s"><img src="%s" alt="%s" /></a></li>', get_permalink($post->ID), $post->post_title, $image, $post->post_title);
    
    		}
    		?>
    
    	</ul>
    	<div class="clear"></div>
    </div>

    With this code the images of featured posts are showing up but not the title with link. what should i do for that??

Topic Closed

This topic has been closed to new replies.

About this Topic