One Headline 100% in TwentyTen Theme

Hi,

I'm trying to figure out the best way to get one "featured" headline, 100% width at the top of the TwentyTen theme.

Is there an easy way to handle this? A plugin that is not a slider. It should only show one headline and image with a link to the story and a list of the number of comments.

Thank you for your suggestions.

<div id="home-featured">
		<?php
			query_posts( array( 'showposts' => 1, 'tag' => 'featured' ) );
			if( have_posts() ) : while( have_posts() ) : the_post();
		?>	

		<h1 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h1>

		<a href="<?php the_permalink(); ?>" rel="bookmark"><?php the_post_thumbnail('home-featured-thumb', array('class' => 'entry-thumb')); ?></a>

		<hr />

			<?php endwhile; endif; wp_reset_query(); ?>
		</div><!--end #home-featured-->

I decided to paste this code into the index.php file of a child theme and it seems to work - except the featured image (thumbnail) isn't working. At least the headline works.

  • Timothy Bowers
    • Chief Pigeon

    Hey there.

    There is another option with Sticky Posts. Some themes support this better than others. :slight_smile:

    Twenty Eleven supports this. :slight_smile:

    You could add some styling to suit your needs if you wish. :slight_smile:

    If you are looking for something else then how would you envisage featuring it?

    By featured category perhaps? It could pull the latest one maybe?

    Is that what you are thinking here?

    Take care.

  • Timothy Bowers
    • Chief Pigeon

    If you only need the headline and not the whole post you look at putting the <!--more--> right at the beginning.

    Then they have to read more for it all. :slight_smile:

    Or you would need to edit the theme files to alter how this functionality works, removing the call for content and such.

    Thanks.

  • LPH
    • Site Builder, Child of Zeus

    Thank you again.

    I wrapped the code I posted earlier into a is_front_page statement so that the headline only shows on the front page. I'm a 15 year cut/paste person who decided it was time to read books and websites on php - and so I'm learning!

    Now, it turns out the featured story image is not showing. I'm not sure if this is because the code is wrong or something else is happening.

    Anyway - please let me know if this looks okay?

    http://www.insanepolitics.com

    Should the height be adjusted?
    Should I go ahead and try to get an image to show?
    Are there any other suggestions you recommend?

    Thank you!

  • Timothy Bowers
    • Chief Pigeon

    I think that looks good. Not sure where you lost the thumbnail there, you would need to look over that but I suspect if it isn't removed then it affected the loop somehow?

    If you need an image then sure go for it.

    A couple functions which could help (you only need one):

    http://codex.wordpress.org/Function_Reference/get_the_post_thumbnail

    http://codex.wordpress.org/Function_Reference/the_post_thumbnail (Must be within a loop)

    I think this could work well for you. Maybe a little tweaking of css for some colour or something to really make it stand out.

    If this is for articles you want to make people comment on perhaps have some prepend there like HAVE YOUR SAY:

    Or something to that affect.

    Take care.

  • LPH
    • Site Builder, Child of Zeus

    Thank you again.

    It turns out there was a huge error in my CSS code for the height. I set it to a fixed 300px. Shame on me! The setting is now auto

    #home-featured {
       font-size: 40px;
       font-weight: bolder;
       height: auto;
       line-height: 75px;
       margin-left: 0px
       margin-bottom: 20px;
       position: relative;
       text-align: center;
       text-transform: uppercase;
       width: 100%;
    }

    The image code must be wrong because I made sure the latest post tagged for featured had an image. Nothing shows.

    Sigh. LOL. Guess it's really the fun of the whole project.

  • LPH
    • Site Builder, Child of Zeus

    OK. I'm stuck !

    If you look at http://www.insanepolitics.com then you will see the headline working BUT the post also shows up in the loop below it. I have the readings setting to show 1 post but I guess the sticky is not counting as 1?

    I'm not sure how to use

    $do_not_duplicate = array();

    Also, I tried to create a new loop called loop-frontpage.php but this is turning into a mess.

    Any guidance would be appreciated.

  • LPH
    • Site Builder, Child of Zeus

    Also - I'm getting closer to the image showing up below the headline. The issue is the cropping. It turns out that the code is showing the featured image which must be large.

    <?php
    		if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it.
    
    			the_post_thumbnail( array( 900, auto, true ) ); 
    
    		}
    
    			?>

    Anyway - the array 900, auto, true - is cropping the image but how can I get it to crop the image from the top and not the center?

  • LPH
    • Site Builder, Child of Zeus

    Hi,

    I started a new thread for the latest issue because the loop repeats showing the featured article.

    This is almost resolved with the exception of the cropping issue. The image is cropped to center and not top.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.