Title: Replace a string using add_filter
Last modified: August 21, 2016

---

# Replace a string using add_filter

 *  [halben](https://wordpress.org/support/users/halben/)
 * (@halben)
 * [12 years, 7 months ago](https://wordpress.org/support/topic/replace-a-string-using-add_filter/)
 * How would I change the taxonomy portfolio_category to customer_category?
 * Would an add_filter & str_replace do the job?
 *     ```
       // 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));
       ```
   
 * Thanks,
    Hal

Viewing 1 replies (of 1 total)

 *  Thread Starter [halben](https://wordpress.org/support/users/halben/)
 * (@halben)
 * [12 years, 7 months ago](https://wordpress.org/support/topic/replace-a-string-using-add_filter/#post-4231166)
 * Update:
 * I did something like this, it did replace the portfolio_category to customer_category
   but I was not able to access the category. It keeps kicking me out because once
   it replaces, the portfolio category
    can not be accessible. I would probably 
   need to mirror it, I think. If anyone have a better solution, please help.
 *     ```
       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');
       ```
   

Viewing 1 replies (of 1 total)

The topic ‘Replace a string using add_filter’ is closed to new replies.

## Tags

 * [string](https://wordpress.org/support/topic-tag/string/)
 * [taxonomy](https://wordpress.org/support/topic-tag/taxonomy/)
 * [url](https://wordpress.org/support/topic-tag/url/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 1 participant
 * Last reply from: [halben](https://wordpress.org/support/users/halben/)
 * Last activity: [12 years, 7 months ago](https://wordpress.org/support/topic/replace-a-string-using-add_filter/#post-4231166)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
