I have pretty links enabled, but when I want to retrieve url of custom post type via get_post_pemalink() I get 'not so pretty' link except pretty link.
For example:
function send_ad_analytics_mail($ID, $post) {
$link = get_post_permalink($ID);
$to = 'example@gmail.com';
$subject = 'Post is drafted';
$message = 'You can see it on ' . $link;
$headers = array(
'From: example@example.rs'
);
wp_mail($to, $subject, $message, $headers);
}
add_action('draft_business', 'send_ad_analytics_mail', 10, 2);
And I get an email like this: You can see it on http://example.rs/?post_type=business&p=46934 But what I want is: You can see it on http://example.rs/business/new-jobs/
The issue is the hook you've chosen to use: draft_business
.
I'm guessing that you've got a post type called "business".
And, the hook you are using as hooking into the Post Status Transitions for that post.
However, because you have draft_business
, this is hooking the status as the post is transitioned to the status of draft
. A non-published post will never have a pretty permalink, therefore this hook will never return a pretty permalink, but always an "ugly" one as you have shown.