Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.