A challenge for the experts! Editing blog post layout on homepage
-
Hello,
My url is http://www.sapnamagazine.com.
I’m pretty inexperienced with .php but I spliced together some stuff to edit my default.php, and came up with a format that does the following:
– in the top area, display the most recent post from 3 different categories
– in the bottom area, display the most recent posts from the blog category.What I want to do:
– change the top area (3 boxes underneath the slideshow) to display the 3 most recent posts, no matter what category they’re from (even if they’re from the same category).
– in those top 3 boxes, I’d like to exclude two categories, numbers 9 and 168.
For that top area, when we release new boxes under the slideshow, I go into default.php and edit the line that says
$cats = array(7,159,3);
Where 7, 159 and 3 would be the three categories in the boxes. I know I have to change this line but don’t know what to do…
The entire code for my default.php is below.
Thank you so much in advance!
Mar———–
<div class=”box”>
<?php /* THIS IS WHERE YOU INPUT THE ARRAY OF CATEGORY IDs */
include(TEMPLATEPATH . ‘/includes/version.php’);$cats = array(7,159,3);
/* DO NOT EDIT BELOW */
foreach($cats as $key => $catz)
{?>
<div class=”post <?php
if (($key + 1) % 3 == 0)
{
echo ” fix2″;
}
else if (($key + 1) % 3 == 2)
{
echo ” margin”;
}
?>”><div class=”post-content”>
<?php /* EDIT THE showposts= NUMBER BELOW FOR MORE POSTS IN EACH CAT */
$my_query = new WP_Query(‘cat=’.$catz.’&showposts=1′); while ($my_query->have_posts()) : $my_query->the_post(); if ( $post->ID == $do_not_duplicate ) continue; update_post_caches($posts); $do_not_duplicate = $post->ID; ?>
<?php if ( get_post_meta($post->ID, ‘image’, true) ) { ?> <!– DISPLAYS THE IMAGE URL SPECIFIED IN THE CUSTOM FIELD –>
<img src=”<?php echo bloginfo(‘template_url’); ?>/thumb.php?src=<?php echo get_post_meta($post->ID, “image”, $single = true); ?>&w=164&&h=100&&zc=1&q=95″ alt=”<?php the_title(); ?>” height=”100″ width=”164″ class=”home_thumb” />
<?php } else { ?> <!– DISPLAY THE DEFAULT IMAGE, IF CUSTOM FIELD HAS NOT BEEN COMPLETED –>
<img src=”<?php bloginfo(‘template_directory’); ?>/images/no_img_homepage.jpg” alt=”” width=”164″ height=”100″ class=”th” />
<?php } ?>
<?php endwhile; ?>
<h2>” href=”<?php the_permalink() ?>” rel=”bookmark”><?php the_title(); ?></h2>
<p><b><?php the_time(‘F d, Y’); ?></b><font color=”white”>_</font><?php echo strip_tags(get_the_excerpt(), ”); ?><span class=”continue”>” href=”<?php the_permalink() ?>”> Read on!</span></p>
</div>
<div class=”posted-in”>
<h3 class=”posted”>More <?php the_category(‘, ‘) ?><span class=”comments”><?php comments_popup_link(‘Discuss (0)’, ‘Discuss (1)’, ‘Discuss (%)’); ?></span></h3>
</div>
</div><!–/post–>
<?php if (($key + 1) % 3 == 0) { ?><div class=”3fclear”></div><?php } ?>
<?php } ?>
<div class=”fix” style=”height:10px”></div>
</div><!–/box–>
<img src=”http://www.sapnamagazine.com/wp-content/themes/gazette/gazette/images/the_sapna_blog.jpg”>
<div class=”bigbox”>
<?php
include(TEMPLATEPATH . ‘/includes/version.php’);$categories = “168”; // comma-seperated list of categories to show
$the_query = new WP_Query(‘cat=-‘. $ex_feat . ‘,-‘ . $ex_vid . ‘,’ . $categories . ‘&showposts=’ . $showposts . ‘&orderby=post_date&order=desc’);
$counter = 0;
$paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 5; query_posts(“cat=5&paged=$paged”);
while ($the_query->have_posts()) : $the_query->the_post(); $do_not_duplicate = $post->ID;
?><div class=”bigpost”>
<div class=”bigpost-content”>
<?php if ( get_post_meta($post->ID, ‘image’, true) ) { ?> <!– DISPLAYS THE IMAGE URL SPECIFIED IN THE CUSTOM FIELD –>
” href=”<?php the_permalink() ?>” rel=”bookmark”><img src=”<?php echo bloginfo(‘template_url’); ?>/thumb.php?src=<?php echo get_post_meta($post->ID, “image”, $single = true); ?>&w=197&&h=120&q=95″ alt=”<?php the_title(); ?>” height=”120″ width=”197″ class=”bighome_thumb” />
<?php } else { ?> <!– DISPLAY THE DEFAULT IMAGE, IF CUSTOM FIELD HAS NOT BEEN COMPLETED –>
<img src=”<?php bloginfo(‘template_directory’); ?>/images/no_img_homepage.jpg” alt=”” class=”th” />
<?php } ?>
<h2>” href=”<?php the_permalink() ?>” rel=”bookmark”><?php the_title(); ?></h2>
<p><b><?php the_time(‘F d, Y’); ?></b><font color=”white”>_</font><?php echo strip_tags(get_the_excerpt(), ”); ?><span class=”continue”>” href=”<?php the_permalink() ?>”>Read full entry</span></p>
</div>
</div><!–/post–>
<?php endwhile; ?>
</div><!–/bigbox–>
-
If you look at the footer of your blog you will find a “Powered by WordPress” link and if click it you will find you have a wordpress.org blog for self hosting. You have posted to the wordpress.com forum where we cannot help you. The correct support forum for your software is here > http://wordpress.org/support
-
- The topic ‘A challenge for the experts! Editing blog post layout on homepage’ is closed to new replies.