Guest User

Untitled

a guest
Feb 27th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.49 KB | None | 0 0
  1. <?php
  2.  
  3. // Error: Notice: Trying to get property 'post_name' of non-object in /path/to/wordpress/functions.php on line 616
  4.  
  5. function change_post_types_slug( $args, $post_type ) {
  6.  
  7.  
  8.   if ( 'lead_page' === $post_type ) {
  9.  
  10.     $id = isset($_GET[ 'post' ]) ? $_GET[ 'post' ] : '';
  11.     $location = get_field('leadpage_location', $id);
  12.     $args['rewrite']['slug'] = $location->post_name;
  13.  
  14.   }
  15.  
  16.   return $args;
  17. }
  18.  
  19. add_filter( 'register_post_type_args', 'change_post_types_slug', 10, 2 );
Advertisement
Add Comment
Please, Sign In to add comment