Forum Replies Created

Viewing 1 replies (of 1 total)
  • If you want that your plugin supports Custom Post Types, replace your functions in wp-hashed-ids.php with following codes:

    function hashed_id() {
        global $wp_rewrite;
        add_rewrite_tag('%hashed_id%','([^/]+)');
        
        foreach ( get_post_types( array('_builtin'=>false),'names') as $post_type ) {
            $permalink =  get_option( $post_type.'_structure' );       
            if (!empty($permalink) && false !== strpos( $permalink, '%hashed_id%' )) {
                add_filter('post_type_link', '_hashed_id_custom_link', 10, 2); 
                add_filter('parse_request', '_hashed_id_parse_request');
            }
        }
    }
    
    function _hashed_id_custom_link($permalink, $post) {
       $hashids = _hashed_id_get_instance();
        return str_replace('%hashed_id%', $hashids->encode((int)$post->ID), $permalink);
    }
    • This reply was modified 7 years, 5 months ago by mdayan. Reason: missing code
Viewing 1 replies (of 1 total)