I need to use the slug in a template, but so far I can’t find any template tag which will return the slug. Is there one? A plugin? A trick? Secret-handshake?
More specifically, I’m making an image for each post. This image will have the slug as it’s name, e.g. “about-the-birds-on-the-roof.gif” If I could suck the slug into the template, I’d be able to reference these images automatically, and not have to fool with the cumbersome upload interface and HTML copying in WP.
Thanks for the help, but also for the charming sarcasm. Assuming I searched was correct. Assuming I searched exactly for “return the slug” would however be false. Try searching for only “the slug” and see how many of the useful posts from your search turn up on the first results page.
I’m trying to do exactly the same thing as mbalara. I haven’t found anything helpful in the forums though. The closest template tag to what I need is <?php permalink_anchor('title'); ?>. That tag doesn’t echo the post slug – only an anchor (obviously). But since the slug is returned in the html code as <a id=”post-slug”></a> I think this widely spread problem must have a solution…
PS: <?php echo $post->post_name; ?> doesn’t seem to work.