GUID appears incorrect
-
I just dumped $post and I noticed that my guid is showing an incorrect value (even though nothing appears to be broken).
My GUID shows: https://url.com/my_cpt/392// while other post types show a non-rewritten url, something like https://url.com/?post_type=other_cpt&p=448.
The actual working address is https://url.com/my_cpt/amsterdam/een-nieuwe-titel-392/
This is how I rewrote the permalinks:
function sd_change_post_type_link( $link, $post = 0 ) { $city = get_field('sd_city', $post->ID); if ( $post->post_type == 'my_cpt' ){ return home_url( 'my_cpt/' . strtolower($city) . '/' . $post->post_name . '-' . $post->ID .'/'); // return $link; } else { return $link; } } function sd_add_rewrite_rules() { add_rewrite_rule( 'my_cpt/([^&]+)/([^&]+)-([0-9]+)/?$', 'index.php?post_type=my_cpt&p=$matches[3]&city=$matches[1]&name=$matches[2]', 'top' ); }
Like I said it all appears to be working, but just to be safe, I’d like to get the GUID to show the correct value.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘GUID appears incorrect’ is closed to new replies.