Suppose that I have a blog with few posts per month, and no comments, and I don’t want to show posts in single post pages, but always “in context” (say, together with the posts in its month – or perhaps a week?). To accomplish this, I’d need to use permalinks with fragment identifiers (#), among other things. I wonder if this is supported, or if someone can point me to some resource or discussion.
Edited: I posted in my own answer the details of my implementation.
3 Answers
There are two hooks named 'pre_post_link'
and 'post_link'
. Their first argument – which you can change – is the permalink. So …
add_filter( 'pre_post_link', 'wpse_42406_change_permalink', 10, 2 );
function wpse_42406_change_permalink( $permalink, $post )
{
// change the permalink, let it point to an archive etc.
return $permalink;
}
… will change the output.
In your loop you probably use something like …
<li id="post-<?php the_ID(); ?>">
Your permalink could then point to the archive page of your choice plus #post-$post->ID
. For example:
http://example.com/2012/04/#post-42