1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

[WP_HELP] Plugin EDD: trying to remove the slug and change the download_category taxonomy.

Discussion in 'PHP & Perl' started by Sheraf, Feb 11, 2016.

  1. Sheraf

    Sheraf Registered Member

    Joined:
    Jan 19, 2014
    Messages:
    61
    Likes Received:
    8
    Hi,


    I've been trying since yesterday to remove the slug and change the category taxonomy from EDD plugin.


    The default slug is "download" and category taxonomy is "download/categoy"
    So currently:
    http://domain.com/download/ -> list all the downloads
    http://domain.com/download/category/$cat_name -> list all the downloads in that category
    http://domain.com/download/$file_name -> show a file to download.


    What i'd like is the following:
    http://domain.com/$cat_name -> list the $cat_name category
    http://domain.com/$cat_name/$file_name -> show the file item


    What i've done so far:


    `<?php
    define('EDD_SLUG', 'download');
    function vendd_child_edd_download_category_args( $category_labels ) {
    $slug = defined( 'EDD_SLUG' ) ? EDD_SLUG : 'downloads';

    // modify the "the-new-category-label" below to your liking
    //print_r($category_labels);
    $category_labels['rewrite'] = array('slug' => '/', 'with_front' => false, 'hierarchical' => true );
    $category_labels['hierarchical'] = False;
    return $category_labels;
    }
    add_filter( 'edd_download_category_args', 'vendd_child_edd_download_category_args' );


    ?>`
    and i installed the WP Permastructure to edit the slug of EDD:
    https://i.imgur.com/rZI5wBy.png


    (also i have my custom structure set to /blog/%postname/ as i want to separate the blog section from the main website)




    all of this make the category displayed as i want:
    http://domain.com/$cat_name
    and the item as well:
    http://domain.com/$cat_name/$item_name


    The only issue now, is that any other regular page/post return 404, I believe it's because the slug is set to "/" so any query would go to EDD plugin?
    I just don't know how to fix it, maybe some kind of fallback to regular page/post if not found or something like that.


    I probably have spent more that 8 hours on this now, it's driving me crazy :/


    Any help would be very much appreciated.
    Thanks!
     
  2. huake00

    huake00 Newbie

    Joined:
    Jun 20, 2008
    Messages:
    3
    Likes Received:
    0
    You can custom WordPress Rewrite Rules for it.
     
  3. Sheraf

    Sheraf Registered Member

    Joined:
    Jan 19, 2014
    Messages:
    61
    Likes Received:
    8
    I found the solution, needed a plugin to edit custom taxonomy, working good now.