Grow your CSS skills. Land your dream job.

WordPress Blog Loop in Footer

  • # October 1, 2011 at 9:31 pm

    I’m trying to figure out how to have a latest post blog loop on every page in my footer. This is my theme: http://lwebdesigns.net/blog/. How do you make a loop for the blog content on every page?

    This is the code I am using:

    Footer:


    Latest Post


    < ?php if ( ! have_posts() ) : ?>

    Not Found


    Apologies, but no results were found for the requested archive. Perhaps searching will help find a related post


    < ?php endif; ?>

    < ?php while ( have_posts() ) : the_post(); ?>

    < ?php the_time('M
    j') ?>


    ">< ?php wpe_excerpt('wpe_excerptlength_teaser', 'wpe_excerptmore'); ?>


    < ?php endwhile; ?>

    Functions:

    < ?php function wpe_excerptlength_teaser($length) {
    return 8;
    }
    function wpe_excerptlength_index($length) {
    return 30;
    }
    function wpe_excerptmore($more) {
    return '...';
    } ?>
    # October 3, 2011 at 1:47 pm

    You’ll need to query the posts to make sure that only one shows up:

    < ?php query_posts( 'posts_per_page=1' ); ?>
    < ?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

    < ?php endwhile; ?>

    < ?php else: ?>

    < ?php endif; ?>
    # October 3, 2011 at 5:57 pm

    This just creates errors when I put the first two lines in the place of the original. If I copy this in instead of my loop it does nothing.

    # October 3, 2011 at 5:59 pm

    Also, I just want posts from the blog feed. Does this only pull posts from the blog feed?

    # October 3, 2011 at 7:25 pm

    Latest Post



    < ?php query_posts( 'posts_per_page=1' ); ?>
    < ?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    < ?php the_time('M
    j') ?>


    ">< ?php wpe_excerpt('wpe_excerptlength_teaser', 'wpe_excerptmore'); ?>

    < ?php endwhile; ?>

    < ?php else: ?>

    Not Found



    Apologies, but no results were found for the requested archive. Perhaps searching will help find a related post


    < ?php endif; ?>
    # October 3, 2011 at 7:31 pm

    You’re a genius! <3

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".