Hmm, still no luck any hacks/plugins? I’m probably going to look into writing a hack/plugin for this soon. If anyone has any pointers or helpful hints for this I would greatly appreciate it.
Try this. Define this function somewhere (in a plugin, in your template somewhere, whatever you prefer.)
Then, call latest_in_category_link('photos');
to display the link, or $link = latest_in_category_link('photos',false);
to just return the value (if you want to do something with it.)
<?php
function latest_in_category_link($catname, $disp = true)
{
$blah = '';
$my_query =& new WP_Query('category_name=photos&showposts=1');
while( $my_query->have_posts() )
{
$my_query->the_post();
$blah = '<a href="' . apply_filters('the_permalink', get_permalink($my_query->post->id)) .
'" title="Latest post in the ' . htmlentities($catname) . ' category">' .
apply_filters('the_title', $my_query->post->post_title, $my_query->post) . '</a>';
}
if( $disp ) echo $blah;
return $blah;
}
?>
DISCLAIMER: This is untested and may cause big errors. If you have problems, just respond to this post, and I’ll try to help.
Thanks for the input. This could work for the short term. I’m hoping to set something up with a more permanent link so that people can bookmark the photoblog. I’m going to have to figure something out that processes before loading the page.
Aha.
Well, you could create a custom template file for that category. Get the category ID number, and then go into your main template directory. Open up category.php (if it’s there), or archive.php (if it’s not) and save it as category-6.php
, but replace “6” with the ID of the photo category.
Then, change the code of that file to not loop through posts, but instead just show one and break out of The Loop. Since I don’t have access to your template to tell you exactly how to do this, the super-quick and super-dirty way that will almost certainly work is to just put a break;
right before the endwhile;
.
It’s probably designed to loop through a bunch of posts, and usually that loop is wrapped in while( have_posts() ): the_post;
and endwhile;
Right before the endwhile;
, you put a break;
which says, “Break out of this loop, and don’t continue.” Since it already finished the first run through, it’ll just show one post, and then quit.
Then, the link to give is just http://your.site.com/category/photos/