Viewing 1 replies (of 1 total)
  • Plugin Support Nayeem Hyder

    (@nriddhi)

    Hi,

    You can adjust custom URL structure with this code adding in your theme functions.php,

    add_filter('post_type_link', 'wpdm_custom_post_type_link_v1', 1, 3);
    
    function wpdm_custom_post_type_link_v1( $link, $post = 0 ){
        if ( $post->post_type == 'wpdmpro' ){
            return home_url( 'download/version/'. $post->ID.'/setup' );
        } else {
            return $link;
        }
    }
    
    add_action( 'init', 'wpdm_custom_post_type_link_v2' );
    
    function wpdm_custom_post_type_link_v2(){
        add_rewrite_rule(
            'download/version/([0-9]+)/setup',
            'index.php?post_type=wpdmpro&p=$matches[1]',
    		'top' );
    		
    	}

    It will give you POST_ID instead of numeric number 1,2,3…
    and please flush the permalink settings from WordPress dashboard Settings > Permalinks pressing Save Changes for watching the changes.

    Thanks.

    • This reply was modified 6 years, 2 months ago by Nayeem Hyder.
Viewing 1 replies (of 1 total)

The topic ‘Change Permalink Structure’ is closed to new replies.