Support Forum

Any way to change anchors?

KV kvr28
kvr28
Member

right now when you click on recent post link it will take you directly to that post, is there a way where instead say I have display set at 8 posts per topic and there are 12 posts, if the link to latest post is clicked, it will take you to the top of page 2 instead of to post number 12?

15 Answers

New Answer

YS Yellow Swordfish
Yellow Swordfish
Member

Currently no way at all I am afraid.

We could introduce a filter for you to use so that the url fragment could be removed but then it would be across the board and imposed everywhere. If you would like to do that it can be arranged.

KV kvr28
kvr28
Member

I would like to try it and see how it works, thanks yellow

MP Mr Papa
Mr Papa
Member

the filter would be available in the next version 5.5.3…

YS Yellow Swordfish
Yellow Swordfish
Member

The filter will simply be called ‘sph_forum_url’ and the only parameter is the constructed url being requested. So it would be a simple matter to remove the post ID fragment and then return the massaged url. This will be in the 5.5.3 release.

YS Yellow Swordfish
Yellow Swordfish
Member

You’re welcome.
Shout nearer the time if you need advice on how to use it if you still want to. Again a custom or child theme would be useful for this.

KV kvr28
kvr28
Member

where would I find this filter? and what would I do with it?

YS Yellow Swordfish
Yellow Swordfish
Member

I will have to come back to this later today. Struggling with it a bit as I am starting to think that WordPress might not load anythiung early enough to catch this. But will investigate further later.

YS Yellow Swordfish
Yellow Swordfish
Member

Ok – try adding this to your Simple:Press theme spFunctions file:

add_filter('sph_forum_url', 'test');
function test($u) {
    $p = strpos($u, '#');
    if($p) $u = substr($u, 0, $p);
    return $u;
}

Important to realise, of course, that this will change the urls across the board. Although I am only 95% sure it will change all of them.

YS Yellow Swordfish
Yellow Swordfish
Member

Good to hear. Hopefully it really does get them all. I wonder if some might seem a bit weird though. Like search results for example.

KV kvr28
kvr28
Member

it does, and I actually prefer it like that, I’d rather people being looking through the newest posts firsts instead of three year old threads