Custom Permalink with Dynamic Taxonomy for Custom Post Type – Works, but breaks other permalinks

If you’re running WordPress 3.0.1 or later, I believe your problem lies with the ‘post_type_link’ filter declaration and function arguments.

When the ‘post_type_link’ filter is applied, it passes the following 4 arguments:

apply_filters('post_type_link', $post_link, $post, $leavename, $sample);

But your function accepts $post_link and $id.

Try the following adjustments:

function custom_post_link( $post_link, $post ) {

    if ( $post->post_type != 'course-segment')
        return $post_link;

    $course="course-segment";
    if( $terms = wp_get_object_terms( $post->ID, 'course' ) )
        $course = $terms[0]->slug;

    return str_replace( '%course%', $course, $post_link );

}
add_filter( 'post_type_link', 'custom_post_link', 1, 2 );

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)