Hello, Does anyone know the smallest piece of code to add to display the last 10 post titles from the category I'm in atm? Also, have the <a> tag on them, that will go to the permalink (basic linking) Thank you - will add rep - Scorpiono
hi there First you must have the plugin called exec-php installed and activated so that you can insert php code into your posts next: try inserting this snippet of code in your post: <p>< ?php wp_get_archives('type=postbypost&limit=10&format=custom&cat_ID=?'); ?></p> Code (markup): you see where cat_ID=? replace the question mark with your category number..you can find that by going to Manage/Categories and place your cursor on the edit link next to the category and you will see the id number on your browser's taskbar let me know if this works
I'm thinking of putting this on the sidebar, and it will grab the current category by itself, anyway?
Answer: <h2>Latest posts:</h2> <?php while (have_posts()) : the_post();?> <?php $postCount++;?> <a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>" style="border-bottom:1px dotted #ddd;line-height:2em;">» <?php the_title(); ?></a><br /> <?php endwhile; ?>
This currently works for me <h2>Last Posts</h2> <ul> <?php $posts = get_posts('numberposts=10&offset=0'); foreach ($posts as $post) : ?> <li><a href="<?php the_permalink(); ?>" title="<?php the_title() ?>"><?php the_title() ?></a></li> <?php endforeach; ?> </ul> PHP: this will display the last 10 post made, change numberposts=10 to how ever many last post u want displayed. (e.g. numberposts=20 will show 20 post) change &offset=0 to show only post after this value (e.g. &offset=1 would show all last post execpt the most recently posted)