![]() |
|
||||||
|
|
Thread Tools | Display Modes |
|
#1
|
||||
|
||||
|
One of the most popular requests is how to create additional sections for the homepage. Currently the code that's built into the home.php file is tied to the Theme Options page, so the easiest way to customize this is by resorting back to the original way we had coded these types of sections.
Creating an additional block within .homepageleft (first section below the FCG) on the homepage Step #1 Open up your home.php file, and copy this code: Code:
<div class="hpfeatured">
<h3><?php echo cat_id_to_name(get_theme_mod('featured_top_left')); ?></h3>
<?php $recent = new WP_Query("cat=".get_theme_mod('featured_top_left')."&showposts=".get_theme_mod('featured_top_left_num')); while($recent->have_posts()) : $recent->the_post();?>
<?php if( get_post_meta($post->ID, "thumb", true) ): ?>
<a href="<?php the_permalink() ?>" rel="bookmark"><img class="thumb" src="<?php bloginfo('template_directory'); ?>/tools/timthumb.php?src=<?php echo get_post_meta($post->ID, "thumb", $single = true); ?>&h=<?php echo get_theme_mod('featured_top_left_thumb_height'); ?>&w=<?php echo get_theme_mod('featured_top_left_thumb_width'); ?>&zc=1" alt="<?php the_title(); ?>" /></a>
<?php else: ?>
<?php endif; ?>
<strong><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></strong>
<?php the_content_limit(80, ""); ?>
<hr/>
<?php endwhile; ?>
<?php if(get_theme_mod('featured_top_left')) : ?>
<strong><a href="<?php echo get_category_link(get_theme_mod('featured_top_left')); ?>" rel="bookmark"><?php _e("Read more posts from ", 'studiopress'); echo get_cat_name(get_theme_mod('featured_top_left')); ?></a></strong>
<?php endif; ?>
</div>
Paste it just below where you found it - in other words, you'll have this code now twice in your home.php file, one on top of the other. In order to easily work with the code, take this code: Code:
<?php $recent = new WP_Query("cat=".get_theme_mod('featured_top_left')."&showposts=".get_theme_mod('featured_top_left_num')); while($recent->have_posts()) : $recent->the_post();?>
Code:
<?php $recent = new WP_Query("cat=1&showposts=1"); while($recent->have_posts()) : $recent->the_post();?>
Step #3 You will also need to change the Headline code, so take this code: Code:
<h3><?php echo cat_id_to_name(get_theme_mod('featured_top_left')); ?></h3>
Code:
<h3>Featured Category</h3> Locate this code: Code:
<strong><a href="<?php echo get_category_link(get_theme_mod('featured_top_left')); ?>" rel="bookmark"><?php _e("Read More Posts From This Category"); ?></a></strong>
Code:
<strong><a href="URL GOES HERE">More Posts From CATEGORY NAME GOES HERE</a></strong> This entails the same steps as outlined for .homepageleft except wherever .homepageleft uses featured_top_left .homepageright uses featured_top_right Creating an additional block within .homepagebottom on the homepage Step #1 Open up your home.php file, and copy this code: Code:
<div class="hpbottom">
<h3><?php echo cat_id_to_name(get_theme_mod('featured_bottom')); ?></h3>
<?php $recent = new WP_Query("cat=".get_theme_mod('featured_bottom')."&showposts=".get_theme_mod('featured_bottom_num')); while($recent->have_posts()) : $recent->the_post();?>
<?php if( get_post_meta($post->ID, "thumb", true) ): ?>
<a href="<?php the_permalink() ?>" rel="bookmark"><img class="thumb" src="<?php bloginfo('template_directory'); ?>/tools/timthumb.php?src=<?php echo get_post_meta($post->ID, "thumb", $single = true); ?>&h=<?php echo get_theme_mod('featured_bottom_thumb_height'); ?>&w=<?php echo get_theme_mod('featured_bottom_thumb_width'); ?>&zc=1" alt="<?php the_title(); ?>" /></a>
<?php else: ?>
<?php endif; ?>
<strong><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></strong>
<?php the_content_limit(350, __("[Read more of this review]", 'studiopress')); ?>
<hr/>
<?php endwhile; ?>
<?php if(get_theme_mod('featured_bottom')) : ?>
<strong><a href="<?php echo get_category_link(get_theme_mod('featured_bottom')); ?>" rel="bookmark"><?php _e("Read more posts from ", 'studiopress'); echo get_cat_name(get_theme_mod('featured_bottom')); ?></a></strong>
<?php endif; ?>
</div>
Paste it just below where you found it - in other words, you'll have this code now twice in your home.php file, one on top of the other. In order to easily work with the code, take this code: Code:
<?php $recent = new WP_Query("cat=".get_theme_mod('featured_bottom')."&showposts=".get_theme_mod('featured_bottom_num')); while($recent->have_posts()) : $recent->the_post();?>
Code:
<?php $recent = new WP_Query("cat=1&showposts=1"); while($recent->have_posts()) : $recent->the_post();?>
Step #3 You will also need to change the Headline code, so take this code: Code:
<h3><?php echo cat_id_to_name(get_theme_mod('featured_bottom')); ?></h3>
Code:
<h3>Featured Category</h3> Locate this code: Code:
<?php if(get_theme_mod('featured_bottom')) : ?>
<strong><a href="<?php echo get_category_link(get_theme_mod('featured_bottom')); ?>" rel="bookmark"><?php _e("Read more posts from ", 'studiopress'); echo get_cat_name(get_theme_mod('featured_bottom')); ?></a></strong>
Code:
<strong><a href="URL GOES HERE">More Posts From CATEGORY NAME GOES HERE</a></strong> Open style.css and look for these selectors: Code:
.hpbottom {
float: left;
width: 590px;
margin: 0px;
padding: 10px;
display: inline;
}
Code:
.hpfeatured {
background: #FFFFFF url(images/featuredtop.gif) top no-repeat;
float: left;
width: 280px;
margin: 0px;
padding: 10px 10px 10px 10px;
border: 1px solid #DDDDDD;
}
Code:
.hpbottom {
float: left;
width: 590px;
margin: 0px 0px 10px;
padding: 10px;
display: inline;
}
Code:
.hpfeatured {
background: #FFFFFF url(images/featuredtop.gif) top no-repeat;
float: left;
width: 280px;
margin: 0px 0px 10px;
padding: 10px 10px 10px 10px;
border: 1px solid #DDDDDD;
}
Last edited by SoZo; 06-24-2010 at 11:05 AM. |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to Add Additional Sections to Your Homepage | MVF45 | General Discussion | 13 | 07-08-2010 05:09 PM |
| How to Add Additional Sections to the Homepage | tutorials | General Discussion | 1 | 03-01-2010 08:25 AM |
| How do I add additional Category sections to the homepage | Eski99 | General Discussion | 4 | 11-27-2009 08:27 AM |
| How to Add Additional Sections to Your Homepage | tutorials | General Discussion | 1 | 11-02-2009 10:31 AM |
| How to Add Additional Sections to Your Homepage | tutorials | General Discussion | 1 | 10-14-2009 01:03 PM |
© Copyright 2012 Copyblogger Media LLC · StudioPress™ is a trademark of Copyblogger Media LLC
Privacy Policy | Refund Policy | Terms of Service | Affiliate Program | Contact Us