Advertisement
Guest User

Untitled

a guest
Sep 20th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. add_filter( 'post_link', 'future_permalink', 10, 3 );
  2.  
  3. function future_permalink( $permalink, $post, $leavename ) {
  4. /* for filter recursion (infinite loop) */
  5. static $recursing = false;
  6.  
  7. if ( empty( $post->ID ) ) {
  8. return $permalink;
  9. }
  10.  
  11. if ( !$recursing ) {
  12. if ( isset( $post->post_status ) && ( 'future' === $post->post_status ) ) {
  13. // set the post status to publish to get the 'publish' permalink
  14. $post->post_status = 'publish';
  15. $recursing = true;
  16. return get_permalink( $post, $leavename ) ;
  17. }
  18. }
  19.  
  20. $recursing = false;
  21. return $permalink;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement