Advertisement
Guest User

When using get_post_permalink on wp_insert_post the old perm

a guest
Apr 25th, 2017
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.68 KB | None | 0 0
  1. <?php
  2. /*
  3. Plugin Name: When using get_post_permalink on wp_insert_post the old permalink is returned
  4. Author: Addcode
  5. Version: 1.0
  6. */
  7.  
  8. /*
  9.  *  To replicate the issue the following database settings need to be true:
  10.  *  - Make 'Example post type' translatable
  11.  *  - Translate custom posts slugs (via WPML String Translation).
  12.  */
  13. add_action('init', function(){
  14.     register_post_type('example', array(
  15.         'label' => 'Example post type',
  16.         'public' => true,
  17.     ));
  18. });
  19.  
  20. // Trigger cache
  21. add_action( 'pre_post_update', function() {
  22.     get_permalink();
  23. });
  24.  
  25. // Try logging new permalink
  26. add_action( 'post_updated', function($post_id) {
  27.     error_log(get_permalink( $post_id ));
  28. }, 10, 1);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement