mercredi 3 février 2016

How to change custom post type slug in wordpress

I install edd plugin and add products. When I click on a product for single page or click any edd category the link generated http://site_url/downloads/category/recent-issues/ by plugin. Now I want to change the slug of post type.

Like

http://site_url/downloads/category/recent-issues/

To

http://site_url/issues/category/recent-issues/

I searched from google and found this code.

function add_custom_rewrite_rule() {
    $current_rules = get_option('rewrite_rules');

    if( ($current_rules) ) {
        foreach($current_rules as $key => $val) {
            if(strpos($key, 'download') !== false) {
                add_rewrite_rule(str_ireplace('download', 'issues', $key), $val, 'top');
            } // end if
        } // end foreach

    } // end if/else

    // ...and we flush the rules
    flush_rewrite_rules();

} // end add_custom_rewrite_rule
add_action('init', 'add_custom_rewrite_rule');

But this code not working. "Download" is the post type of edd products.

So how can I change the slug of edd post type.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire