0

My articles are not standard posts but custom post types (not sure about how to formulate this exactly). When viewing an article in single view, the URL is : my_site.com/custom_type_name/article_title, whereas I want: my_site.com/article_title, just like with normal posts.

How to achieve that ?

1 Answer 1

0

Use the post_type_link hook, like this for use hash in link

faq is the example custom post type

add_action( 'post_type_link', 'wpse70763_post_type_link', 10, 2 );
function wpse70763_post_type_link( $link, $post ) {

    $post_type = 'faq';

    if ( $post->post_type === $post_type )
        $link = get_post_type_archive_link( $post_type ) . '#' . $post->post_name;

    return $link;
}

then unset($wp_rewrite->extra_permastructs['faq'])

On the init of your CPT unset the pemastructure

2
  • Thanks but I don't want a hash..
    – drake035
    Oct 29, 2012 at 13:05
  • Yes, this is only a example. You must use the source. This is not the ready solution.
    – bueltge
    Oct 29, 2012 at 21:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.