• when before_delete_post hook, get_permalink failed,
    it return mydomain.com/?p=11111

    but when edit_post hook, get_permalink return correct permalink url.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter laowang1

    (@laowang1)

    How can I get correct permalink url in before_delete_post hook?

    Moderator bcworkz

    (@bcworkz)

    Well, p=1111 style is a valid link to the post ?? But not following your defined permastruct. Your callback is passed the post’s object. You could construct your permalink using your own code and the object’s data. Exactly how depends on what your permastruct is. On a basic level, just append the post’s slug to your site URL.

    For more flexibility, the permastruct is stored in the “permalink_structure” option. You’d then replace all %tags%-like elements in the structure with their proper values for this particular post.

    It probably doesn’t matter, but out of curiosity, why get the permalink of a post that’s going to be deleted?

    Thread Starter laowang1

    (@laowang1)

    I need permalink to get local cached static file path to delete them.
    I found a way to fix that, just disable TRASH, add below line to wp-config.php
    define(‘EMPTY_TRASH_DAYS’,0);

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘when before_delete_post hook, get_permalink failed’ is closed to new replies.