I’m working on a Ajax WordPress website and I have some posts inside homepage.
When I click Show on a post a popup with the post appears and the link changes to example.com/#post-id where id is post ID. This is ok.
I want when someone goes on example.com/#post-3 to accest the post with id 3. I did that too. But I saw a problem:
On permalinks I can’t put #.
My question is how can I transform my permalink into a link with # or how can I change the other way? Which is the better option?
Thanks
EDIT:
My current permalink is this:
/post-%post_id%
and I want to make it into
/#post-%post_id%
If you only want to change this on links called by
the_permalink()
you can filter it. Using your exampleThis will only work directly on
the_permalink()
, and won’t reflect in navigation (menus, next/previous, etc.). You can apply the changes to all permalinks for posts by using thepost_link
filter. This will not work on pages, attachments or custom post types, however.