In WordPress, the Draft post preview will have the below link: mysite.com/?p=2000&preview=true
But I want to custom this link to slug/permalink like: mysite.com/my-category/my-post-slug?preview=true
(This link have only category slug and post slug, it’s the same with published post link).
I am using post_link
hook and use a trick to custom preview link: make the post status publish and switch to draft immediately
. When I do that, the post will create the slug (post_name in the Database).
My code below:
Result: It’s work but it cause some bugs like:
I want to filter that:
Thank you so much.
- Hiện tại chúng tôi có hơn 25 nghìn bài văn mẫu các thể loại.
- Kho tài liệu, đề thi học sinh giỏi các lớp vô cùng phong phú.
- Mỗi ngày cập nhật hơn 100 đề thi chất lượng từ các website bán tài liệu lớn.
Tải đề thi VIP với giá siêu rẻ tại Vip.Dethihsg247.Com