WordPress.org

Ready to get started?Download WordPress

Forums

Using a featured image as a header (4 posts)

  1. DrGiz
    Member
    Posted 9 months ago #

    Hi there I am in the process of developing a theme for my site based around the Pronto, I would very much like to have a featured story at the top that looks like the Top Story section on ReadWrite.

    I have managed to create a featured section at the top of my site using this code, which works very well"

    <div id="featured"> <?php query_posts('posts_per_page=1&cat=2'); ?> <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?> <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2> <small><?php the_time('jS F Y'); ?></small> <p><?php the_excerpt(); ?></p> <p> <a href="<?php the_permalink(); ?>">Read More >></a> </p> <?php endwhile; ?> <?php wp_reset_query(); ?>>
     </div>

    I am calling the featured image for the background using this code:

    <body <?php body_class(); ?>
    		<?php if($src !== '') { echo 'style="background:url( '. $src[0] . ' ) no-repeat center top; width:100%;" ';
    		 } else { echo 'style="background:url(images/default-bg.png) repeat-x;"'; } ?> >

    But the problem I am having is that I cannot find a way to scale the image to the full width of the page or the full height of the div.

    Please can someone help as this is driving me crazy.

  2. alchymyth
    The Sweeper & Moderator
    Posted 9 months ago #

    start by fixing the validation errors
    http://validator.w3.org/check?uri=http%3A%2F%2Fpoliticalticker.co.uk%2F&charset=%28detect+automatically%29&doctype=Inline&group=0

    http://codex.wordpress.org/Validating_a_Website

    for instance, you have html code before the body tag, and faulty CSS class codes...

    for more support, please contact the developer of your theme, as this forum only supports themes from http://wordpress.org/themes/

  3. DrGiz
    Member
    Posted 9 months ago #

    I have fixed my validation errors (there are still a couple but these are because of the side bar widget for recent posts and not my code. I still cannot get the code to work, can some one please help.

  4. WPyogi
    Volunteer Moderator
    Posted 9 months ago #

    for more support, please contact the developer of your theme, as this forum only supports themes from http://wordpress.org/themes/

Reply

You must log in to post.

About this Topic