Where is the function attribute? You missed that. And the number of attributes should be set correctly or not at all. Try this:
function custom_url( $url ) {
if ( $post->post_type == 'post' ) {
$url = "my custom link";
}
return $url;
}
add_filter( 'post_link', 'custom_url', 10 );
Thread Starter
wpman
(@iwpman)
This is my permalink structure:
http://www.domain.com/blog/%post_id%/%postname%/
I want to replace it with http://www.domain.com/blog/%post_id%/ and only in email content,but it doesn’t work.
Here is my code:
function custom_link( $url, $post, $leavename=false) {
if(is_single()){
$url = str_replace($post->post_name.'/','', $url );
}
return $url;
}
add_filter( 'post_link', 'custom_link', 10, 3 );
It works but I don’t want to replace it across my site:
function custom_link( $url, $post, $leavename=false) {
$url = str_replace($post->post_name.'/','', $url );
return $url;
}
add_filter( 'post_link', 'custom_link', 10, 3 );
-
This reply was modified 9 years, 5 months ago by
wpman.
Thread Starter
wpman
(@iwpman)