Search code examples
wordpresspermalinks

Bitly links in wordpress


I use Bitly Wordpress plugin and function wp_get_shortlink(). On simple posts it works fine, but on custom post types the links are not converted and when I share on twitter, my share link is something like domain/?p=43432.

How I can solve my problem?


Solution

  • That VIP plugin doesn't support post_type values beyond "post" by default, but this handy function should solve it for you:

    /**
     * Add Bitly to CPT's
     */
    function my_add_bitly_cpts( $post_types ) {
        $post_types[] = 'my_custom_post_type_name';
        return $post_types;
    }
    add_filter( 'bitly_post_types' , 'my_add_bitly_cpts' );