Jump to content

Rename URL category pathname


halben

Recommended Posts

Hi All,

 

I'm trying to rename a category name from my url. Here it is:

// Register custom post types
add_action('init', 'pyre_init');
function pyre_init() {
    global $data;
    register_post_type(
        'avada_portfolio',
        array(
            'labels' => array(
                'name' => 'Portfolio',
                'singular_name' => 'Portfolio'
            ),
            'public' => true,
            'has_archive' => true,
            'rewrite' => array('slug' => $data['portfolio_slug']),
            'supports' => array('title', 'editor', 'thumbnail','comments'),
            'can_export' => true,
        )
    );

    register_taxonomy('portfolio_category', 'avada_portfolio', array('hierarchical' => true, 'label' => 'Categories', 'query_var' => true, 'rewrite' => true));
    register_taxonomy('portfolio_skills', 'avada_portfolio', array('hierarchical' => true, 'label' => 'Skills', 'query_var' => true, 'rewrite' => true));                               ...

Here is what I have at the moment: 

 

function custom_portfolio_to_customer_category_url($content) {
    $current_path = 'portfolio_category';
    $new_path = 'customer_category';
    $content = str_replace($current_path, $new_path, $content);
    return $content;
}
add_filter('term_link', 'custom_portfolio_to_customer_category_url');

I'm using the str_replace() function to rename portfolio_category to customer_category. "It" did replace it but it seems to have wiped out the category and I'm unable to access the portfolio_category post.

 

Can someone please guide me or assist me in what I'm doing wrong here?

 

Thank you,

Hal

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/283072-rename-url-category-pathname/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.