Home Forums Basel support forum Change permalink of "Projects" i.e. /portfolio/

Change permalink of "Projects" i.e. /portfolio/

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #38811

    vinirossi
    Participant

    I want to use the Custom Post Type “Projects” to present the producers of the wines which my customer sells. Unfortunately, I cannot change the permalink of projects. It seems to be fixed to /portfolio/. What I need ist ../bodegas/url-to-project-element

    #38814

    vinirossi
    Participant

    I googled and found this: https://wordpress.stackexchange.com/questions/38576/is-it-possible-to-change-the-url-of-custom-post-types-to-hide-the-post-type-slug

    add_action( 'init', 'create_post_type' );
    function create_post_type() {
      register_post_type( 'acme_product',
          array(
              'labels' => array(
                  'name' => __( 'Products' ),
                  'singular_name' => __( 'Product' )
              ),
              'public' => true,
              'has_archive' => true,
              'rewrite' => array('slug' => 'products')
          )
      );
    }

    Could you provide a way to filter-hook this via child-theme functions.php?

    #38816

    vinirossi
    Participant
    #38819

    Artem Temos
    Keymaster

    Hello,

    Thank you for the question.

    Unfortunately, there is no such option in our theme and the only one way to change portfolio permalinks structure at the moment is to edit file wp-content/plugins/basel-post-types/basel-post-types.php and replace there a line. You will need to resave your permalinks structure in Dashboard -> Permalinks.

    'rewrite' => array('slug' => 'portfolio'),

    with this one

    'rewrite' => array('slug' => 'your_slug'),

    Regards

    #38838

    vinirossi
    Participant

    Thanks for answering.

    This is not good. Not Update safety…

    Could you implement this as a feature?

    #38845

    vinirossi
    Participant

    Here we go…you should pay me for extending your theme features 😉

    //Rewrite Custom Post type "portfolio" to "my_slug"
    add_filter('register_post_type_args', 'portfolio_to_my_slug', 10, 2);
    function portfolio_to_my_slug($args, $post_type){
     
        if ($post_type == 'portfolio'){
            $args['rewrite']['slug'] = 'my_slug';
        }
     
        return $args;
    }
    #38856

    Artem Temos
    Keymaster

    Hey, thank you for posting this solution here 🙂 Much appreciated!

    #38895

    vinirossi
    Participant

    You are very welcome 🙂

Viewing 8 posts - 1 through 8 (of 8 total)

The topic ‘Change permalink of "Projects" i.e. /portfolio/’ is closed to new replies.