Hacking the archives… any idea how-to?
-
Hello.
I hope you can help me, I am trying to display my most recent post at the top (just normal get post inside the loop) and then I wish to show 3 older posts underneath, (just the titles or titles & excerpts) but not the most recent one.
Is this possible? Plug in? Hacking code? Can anyone help with this?
Thanks,
Carly
-
Here’s a good example to work from:
http://www.daobydesign.com/blog/2007/07/modifying-wordpress-front-page/that’s very helpful, thank you for your reply.
That’s worked great but now my tags aren’t displaying.
Are there any known issues with this method and tagging?
here is my code: Any idea why the tags don’t display on the top (newest news) section?
<?php get_header(); ?> <?php if (have_posts()) : ?> <?php global $post; $the_newest = get_posts('numberposts=1'); $the_newer = get_posts('numberposts=2&offset=1'); $the_new = get_posts('numberposts=3&offset=4&order=DESC&orderby=post_date'); ?> <?php foreach($the_newest as $post) : setup_postdata($post); ?> <div class='headerbox'> <h1 class="header_title"> <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"> <?php the_title(); ?> </a> </h1> <div class='undertitle'> <p><?php the_date(); ?> | <?php the_category(' • '); ?> | <a title='leave a comment on: <?php the_title(); ?>' href="<?php comments_link(); ?>"><?php comments_number('No comments - leave yours?','1 comment - leave yours?','% comments - leave yours?'); ?></a> </div><?php /*close undertitle*/?> </div><?php /*close headerbox*/?> <?php the_content("Continue reading " . the_title('', '', false)); ?> <p class='rightp'> <a title="Comment on: '<?php the_title(); ?>'" href="<?php the_permalink(); ?>"> Comment on: <?php the_title(); ?> »</a></p> <div class='undercontent'> <p><?php the_tags(); ?></p> </div><?php /*close undercontent*/?> <?php endforeach; ?> <?php foreach($the_newer as $post) : setup_postdata($post); ?> <div class="smaller-post"> <h2 class="smaller-post-title"> <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?> </a> </h2> <div class='smaller-meta'> <?php the_excerpt('<span>Read the rest of this entry? »</span>'); ?> Posted in <?php the_category(', ') ?> | On: <?php the_time('F jS, Y') ?> | <a title='leave a comment on: <?php the_title(); ?>' href="<?php comments_link(); ?>"> <?php comments_number('No comments - leave yours?','1 comment - leave yours?','% comments - leave yours?'); ?></a </div> <?php /*close smaller meta*/?> </div> <?php /*close smaller entry*/?> <?php endforeach; ?> <ul> <?php foreach($the_new as $post) : setup_postdata($post); ?> <li><?php the_time('jS M y') ?> | <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a> </li> <?php endforeach; ?> </ul> <?php else : ?> <h2 class="center">Not Found</h2> <p class="center">Sorry, but you are looking for something that isn't here.</p> <?php include (TEMPLATEPATH . "/searchform.php"); ?> <?php endif; ?> <?php get_footer(); ?>
Not sure about a get_posts loop, but this from my notes:
global $wp_query; $wp_query->in_the_loop = true; //but not necessary at 2.9???
Getting the_tags to work in a custom query <?php $my_query = new WP_Query('showposts=10'); ?> global $wp_query; $wp_query->in_the_loop = true; //but not necessary at 2.9??? <?php while ($my_query->have_posts()) : $my_query->the_post(); ?> <?php the_title(); ?> <div class="def"><?php the_content(); ?></div> <?php the_tags(); ?> <?php endwhile; ?>
Eeek I’m not too advanced in this sort of stuff, but I’ll take a look later.
I assume I need to make a couple of changes to the file using your second example?
I’m hopeless, I might give up and donate to my friend’s beer fund and get him to take a look 😛
my hacking about shows the tags, but 6 times. Not sure how I managed that 😉
yeah fixed, it does work!
BUT could you give it the once over to ensure I’ve not done anything silly that will break later?
I honestly owe you mega props for this. Thank you!!
<?php get_header(); ?> <?php if (have_posts()) : ?> <?php global $post; $the_newest = get_posts('numberposts=1'); $the_newer = get_posts('numberposts=2&offset=1'); $my_query = new WP_Query('showposts=1'); global $wp_query; $wp_query->in_the_loop = true; //but not necessary at 2.9??? ?> <?php foreach($the_newest as $post) : setup_postdata($post); ?> <div class='headerbox'> <h1 class="header_title"> <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"> <?php the_title(); ?> </a> </h1> <div class='undertitle'> <p><?php the_date(); ?> | <?php the_category(' • '); ?> | <a title='leave a comment on: <?php the_title(); ?>' href="<?php comments_link(); ?>"><?php comments_number('No comments - leave yours?','1 comment - leave yours?','% comments - leave yours?'); ?></a> </div><?php /*close undertitle*/?> </div><?php /*close headerbox*/?> <?php the_content("Continue reading " . the_title('', '', false)); ?> <p class='rightp'> <a title="Comment on: '<?php the_title(); ?>'" href="<?php the_permalink(); ?>"> Comment on: <?php the_title(); ?> »</a></p> <div class='undercontent'> <?php while ($my_query->have_posts()) : $my_query->the_post(); ?> <?php the_tags(); ?> <?php endwhile; ?> </div><?php /*close undercontent*/?> <?php endforeach; ?> <h2 id='more-recent-posts'>Read more of my recent posts:</h2> <?php foreach($the_newer as $post) : setup_postdata($post); ?> <div class="smaller-post"> <h2 class="smaller-post-title"> <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?> </a> </h2> <?php the_excerpt('<span>Read the rest of this entry? »</span>'); ?> <div class='smaller-meta'> <p>Posted in <?php the_category(', ') ?> | On: <?php the_time('F jS, Y') ?> | <a title='leave a comment on: <?php the_title(); ?>' href="<?php comments_link(); ?>"> <?php comments_number('Read more and comment »','Read more and comment »','Read more and comment »'); ?></a> </p> </div> <?php /*close smaller meta*/?> </div> <?php /*close smaller entry*/?> <?php endforeach; ?> <?php else : ?> <h2 class="center">Not Found</h2> <p class="center">Sorry, but you are looking for something that isn't here.</p> <?php include (TEMPLATEPATH . "/searchform.php"); ?> <?php endif; ?> <?php get_footer(); ?>
- The topic ‘Hacking the archives… any idea how-to?’ is closed to new replies.