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);
// custom homepage loop
function wicked_indexloop() {
query_posts(“posts_per_page=4”);
$counter = 1;
if (have_posts()) : while (have_posts()) : the_post(); ?>
<div id=“post-<?php the_ID() ?>” class=“<?php thematic_post_class() ?>”>
<?php thematic_postheader();
if ($counter == 1 && has_post_thumbnail() && !is_paged()) {
the_post_thumbnail(‘homepage-thumbnail’);
} ?>
<div class=“entry-content”>
<?php the_excerpt(); ?>
<a href=“<?php the_permalink(); ?>” class=“more”><?php echo more_text() ?></a>
<?php $counter++; ?>
</div>
</div><!-- .post –>
<?php endwhile; else: ?>
<h2>Eek</h2>
<p>There are no posts to show!</p>
<?php endif;
wp_reset_query();
}
Home page:
<?php
// calling the header.php
get_header();
// action hook for placing content above #container
thematic_abovecontainer();
?>
<div id="container">
<?php thematic_abovecontent(); ?>
<div id="content">
<?php
// create the navigation above the content
thematic_navigation_above();
// calling the widget area 'index-top'
get_sidebar('index-top');
// action hook for placing content above the index loop
thematic_above_indexloop();
// action hook creating the index loop
//thematic_indexloop();
// a custom homepage loop
wicked_indexloop();
// action hook for placing content below the index loop
thematic_below_indexloop();
// calling the widget area 'index-bottom'
get_sidebar('index-bottom');
// create the navigation below the content
// thematic_navigation_below();
?>
</div><!-- #content -->
<?php thematic_belowcontent(); ?>
</div><!-- #container -->
<?php
// action hook for placing content below #container
thematic_belowcontainer();
// calling the standard sidebar
// thematic_sidebar();
// calling footer.php
get_footer('homepage');
?>
CSS:
body.home div.p1 {
font-size: 120%;
}
body.home div.p1 img {
float: left;
margin-right: 30px;
}
body.home div.p2 {
clear: left;
}
body.home div.p2,
body.home div.p3,
body.home div.p4 {
width: 270px;
float: left;
margin-top: 22px;
}
body.home div.p3 {
margin-left: 30px;
margin-right: 30px;
}
I can’t seem to find any support forum for the book or anyone else who has had this issue???
Please help, thanks