Homepage auto-update on Word Press

1

Currently, I update all the teasers on our homepage by hand: http://www.chicagonewscoop.org/

Clearly this sucks and is unnecessary, but when I redesigned our home page I lost the code that grabbed the latest post in each category (up to the tag) and generated a teaser such as you see now.

Unfortunately, my php skills are too non-existent to bring that auto-update feature back.

Is there some way to fix this state of affairs?

Tags: asked May 24, 2010

Leave a Reply

2 Answers

2

Let me try throwing some template tags into the code from Megan's answer to adapt it to your site:

 <ul><li>
 <?php
 global $post;
 $myposts = get_posts('numberposts=1&&category=1');
 foreach($myposts as $post) :
   setup_postdata($post);
 ?>
   <strong>
     <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
   </strong><br />
   <em>
     <?php the_time('F j, Y'); ?> | <?php the_author_posts_link(); ?>
   </em><br><br>
   <?php the_excerpt(); ?> 
 <?php endforeach; ?>
 </li></ul>

I think that should work. Repeat as needed. You don't need "offset" from the Codex example. Change "category=1" to the ID# found for each category in the control panel. Or use the parameter "category_name=news" instead. For more customization options see docs for permalink, time and date formatting, author posts link, excerpt -- especially the handy Related section at the bottom.

  1. Ooops, didn’t see Megan already had that answer but better, below. If it doesn’t work, look at the PHP of your plugins in /wp-content/plugins/whatever. A plugin might be adding its own filter to the excerpt, so look for a line like add_filter(‘excerpt_more’, ‘something’); or add_filter(‘the_excerpt’, ‘evil_doing’); then delete or comment that line out. http://www.tizag.com/phpT/comment.php You’ll probably have to repeat this process whenever you update the guilty plugin. So if you don’t need it, lose it. My first suspect would be the ShareThis plugin.

  2. Ooops, didn’t see Megan already had that answer but better, below. If it doesn’t work, look at the PHP of your plugins in /wp-content/plugins/whatever. A plugin might be adding its own filter to the excerpt, so look for a line like add_filter(‘excerpt_more’, ‘something’); or add_filter(‘the_excerpt’, ‘evil_doing’); then delete or comment that line out. tizag.com/phpT/comment.php You’ll probably have to repeat this process whenever you update the guilty plugin. So if you don’t need it, lose it. My first suspect would be the ShareThis plugin.

  3. Ooops, didn’t see Megan already had that answer but better, below. If it doesn’t work, look at the PHP of your plugins in /wp-content/plugins/whatever. A plugin might be adding it’s own filter to the excerpt, so look for a line like add_filter(‘excerpt_more’, ‘something’); or add_filter(‘the_excerpt’, ‘evil_doing’); then delete or comment that line out. http://www.tizag.com/phpT/comment.php You’ll probably have to repeat this process whenever you update the guilty plugin. So if you don’t need it, lose it. My first suspect would be the ShareThis plugin.

Leave a Reply

377
0

Depending on how non-existent your PHP is, this should do it: http://codex.wordpress.org/Template_Tags/get_posts

Answer for follow-up question on removing ellipses from post excerpts:

Remove [...] string using Filters

Only in version 2.9 and higher of WordPress

By default, excerpt more string at the end is set to '[...]'. To change excerpt more string using excerpt_more filter, add the following code to functions.php file in your theme:

function new_excerpt_more($more) {
    return '[.....]';
}
add_filter('excerpt_more', 'new_excerpt_more');

For versions 2.8.x and Older

function new_excerpt_more($excerpt) {
    return str_replace('[...]', '...', $excerpt);
}
add_filter('wp_trim_excerpt', 'new_excerpt_more');

from: http://codex.wordpress.org/Template_Tags/the_excerpt

Leave a Reply

263

Your Answer

Please login to post questions.