Viewing 1 replies (of 1 total)
  • Plugin Author PWR Plugins

    (@rexdot)

    Hello @altairfigueira ,

    This will require some custom coding, which unfortunately it’s out of our support scope.

    I found the following tutorial: https://wisdmlabs.com/blog/add-taxonomy-term-custom-post-permalinks-wordpress/

    As we have the powerfolio_modify_portfolio_cpt_slug and elpt_elemenfoliocategory_slug_rewrite filters available (to modify the slugs) I tried it with the following code (added to my functions.php file):

    // Powerfolio plugin: Modify CPT slug for the "elemenfolio" post type
    function powerfolio_modify_portfolio_cpt_slug( $slug ) {
        $slug = 'portfolio/%portfoliocategory%' ;
        return $slug;
    }
    add_filter( 'elpt_portfolio_cpt_slug_rewrite', 'powerfolio_modify_portfolio_cpt_slug', 10);
    
    
    add_filter('post_type_link', 'portfoliocategory_permalink_structure', 10, 4);
    function portfoliocategory_permalink_structure($post_link, $post) {
        if (false !== strpos($post_link, '%portfoliocategory%')) {
            $portfoliocategory_type_term = get_the_terms($post->ID, 'elemenfoliocategory');
            if (!empty($portfoliocategory_type_term) && is_array($portfoliocategory_type_term)) {
    			$check = array_pop($portfoliocategory_type_term)->slug;
                $post_link = str_replace('%portfoliocategory%', $check, $post_link);
            } else {
    			$post_link = str_replace('%portfoliocategory%', 'uncategorized', $post_link);
    		}            
        }
        return $post_link;
    }
    
    // Powerfolio plugin: Modify taxonomy slug for the "portfoliotaxonomy" post type
    function powerfolio_modify_portfoliocategory_tax_slug( $slug ) {
        $slug = 'portfolio';
        return $slug;
    }
    add_filter( 'elpt_elemenfoliocategory_slug_rewrite', 'powerfolio_modify_portfoliocategory_tax_slug', 10);

    But it not worked as expected. I’m just sharing here so maybe it’s useful to you.

    The post type is created on wp-content\plugins\portfolio-elementor\classes\powerfolio_post_types.php

Viewing 1 replies (of 1 total)
  • The topic ‘How to Display Portfolio Category in URL’ is closed to new replies.