Your account expired support, please renew to get your support.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #29724
    associazionelamaruca
    Support Expired

    I need to change the /activity/, /accomodation/, /whatwedo/ slugs. I want to do it from code and permanent, without installing plugins. How should I do?

    #29730

    Hello,

    Please copy this code to the file functions.php ( child-theme):

    function activland_change_post_types_slug( $args, $post_type ) {
    
       /*item post type slug*/   
       if ( 'accommodation' === $post_type ) {
          $args['rewrite']['slug'] = 'your-slug';
       }elseif('activland_activities' === $post_type){
          $args['rewrite']['slug'] = 'your-slug';
        }elseif('activland_whatwedo' === $post_type){
          $args['rewrite']['slug'] = 'your-slug';
       }
    
       return $args;
    }
    add_filter( 'register_post_type_args', 'activland_change_post_types_slug', 10, 2 );
    #29741
    associazionelamaruca
    Support Expired

    I tried to edit as follows but it doesn’t work (The result:THAT LINKS IS BROKEN):

    function activland_change_post_types_slug( $args, $post_type ) {

    /*item post type slug*/
    if ( ‘accommodation’ === $post_type ) {
    $args[‘rewrite’][‘slug’] = ‘dove-dormire’;
    }elseif(‘activland_activities’ === $post_type){
    $args[‘rewrite’][‘slug’] = ‘attivita’;
    }elseif(‘activland_whatwedo’ === $post_type){
    $args[‘rewrite’][‘slug’] = ‘cosa-facciamo’;
    }

    return $args;
    }
    add_filter( ‘register_post_type_args’, ‘activland_change_post_types_slug’, 10, 2 );

    #29754
    This reply has been marked as private.
Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.