Created
September 11, 2022 08:22
-
-
Save megane9988/55e7c000b14b115cfba8e72851a1fe3e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 限定的にパーマリンクを修正する | |
* | |
* @param string $url httpsなどを含むフルのURL. | |
* @param object $post 記事のオブジェクト. | |
* @return string | |
*/ | |
function custom_posttype_permalink( $url, $post ) { | |
if ( is_wp_error( $post ) ) { | |
return $post; | |
} | |
if ( 159 === $post->ID ) { | |
$new_url = 'https://wp.local/hoge/fuga/aaa/'; | |
return $new_url; | |
} | |
return $url; | |
} | |
add_filter( 'post_type_link', 'custom_posttype_permalink', 1, 3 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment