• Hi,
    I asked this earlier but what offspring gave me isn’t exactly what I wanted.(thank you though) On my home pagehere you’ll see a box with new blog posts. What I’d like to do is have the latest 3 posts with the first 10 words of the post, the date and title. Is this possible.The site is hidden from the public so you’ll have to log in using username: testsite pw: nswd2009 – sorry

Viewing 4 replies - 1 through 4 (of 4 total)
  • You can modify my code to use the_excerpt() function.
    For example:

    <?php
    	if (is_front_page()) {
    ?>
    	<h1 class="entry-title">Recent posts</h1>
    	<div class="entry-content">
    		<ul style="list-style-type:none">
    <?php
    	global $post;
    	$myposts = get_posts('numberposts=5');
    	foreach($myposts as $post) :
    		setup_postdata($post);
    ?>
    <li style="font-size:110%">&raquo;&nbsp;<?php the_time('d/m/Y'); ?>
    	&nbsp;&mdash;&nbsp;<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a><br />
    	<?php the_excerpt(); ?>
    </li>
    <?php endforeach;
    }
    ?>
    </ul></div>

    Another option is to use get_the_content() function to get the content and cut it to whatever length you want.

    P.S. I’m not following you ??

    Thread Starter ke vinritt

    (@ke-vinritt)

    P.S. I’m not following you ??

    Heh heh
    Thanks again for your help – I’ll take a look at your suggestion and see what I can come up with.

    Thread Starter ke vinritt

    (@ke-vinritt)

    ok I added the excerpt function and it works the way I want. But I also want to add a ‘continue reading’ link at the end of the excerpt. I tried this

    <?php the_excerpt(); <a href="<?php the_permalink(); ?>">read more ... </a>?>

    but the read more is spaced too far below the text. Any idea how to move the link up? You can see it here
    The site is hidden from the public so you’ll have to log in using username: testsite pw: nswd2009

    That how it looks now:

    <li style="font-size:110%">&nbsp;11/17/2009&nbsp;&nbsp;<a href="https://xaddx.org/cms/post-from-a-new-user/">Post from a new user</a>
        <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis sit amet orci ut mauris imperdiet commodo vitae vitae libero. </p>
    <a href="https://xaddx.org/cms/post-from-a-new-user/">read more ... </a>

    you should place <a href=... inside <p> tag or decrease <p> padding/margin in the stylesheet. You may also try the_content() instead of the_excerpt() – it should handle ‘read more’ link automaticaly. Take a look at this page: https://codex.www.ads-software.com/Template_Tags/the_excerpt

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘latest blog posts with x amount of text’ is closed to new replies.