Issues with Wordpress Loop from sitepoint book 'build your own wicked wordpress theme
Hello, I am very much a newbie to Wordpress and am trying to learn more. At the moment trying to build a child theme for Thematic.
I am working out of Sitepoint book 'build your own wicked wordpress themes' and am having an issue with the setting up a styled index loop for the home page.
In chapter 5.6 the Query_post pulls through 4 posts, one is meant to be styled as a full width feature with thumbnail, the other three styled underneath in box format.
The function pulls through 4 posts fine. But it does not style the image as it should (not floating left), it also creates 2 featured posts, rather than one and it does not pull through the 'read more' function from the parent theme (built on thematic).
If I increase the number of posts being pulled through to 5 then the layout seems OK apart from the extra feature and the thumbnail styling. So I don't think it is simple the CSS that is wrong.
This is the code directly from the support files that come with the book, so you may see why it is particularly frustrating for me as someone trying to learn. I am wondering if the thematic parent theme has been updated since the code was originally written?
The code is:
Function:
// Add support for thumbnails
add_theme_support('post-thumbnails');
set_post_thumbnail_size(540, 300, true);
add_image_size('homepage-thumbnail', 300, 200, true);
I ran into the same problem today and found your post on Google whilst trying to find a solution.
I've found adjusting the CSS styling fixes the layout problem. The posts start from 0, not 1, so you need to change the body.home div.p1 to body.home div.p and decrease the other values by 1, too.
more_text is a deprecated function by the looks of it (thematic/library/legacy/deprecated.php).
I'm using the following for now:
function new_excerpt_more($more) {
global $post;
return ' <a href="'. get_permalink($post->ID) . '">Read More...</a>';
}
add_filter('excerpt_more', 'new_excerpt_more');
I've removed the line <a href="<?php the_permalink(); ?>" class="more"><?php echo more_text() ?></a> as it's not needed now.
An alternative could be to keep the line but change it to <a href="<?php the_permalink(); ?>" class="more">Read More...</a> and add the following function:
function new_excerpt_more( $more ) {
return '';
}
add_filter('excerpt_more', 'new_excerpt_more');
That way it puts 'Read More...' on a new line but removes the [...].
Bookmarks