Tags | WordPress.org

[ad_1]

Hi Kevin,

You will need to use a custom code snippet to make the articles’ permalinks conditional because the plugin allows to specify one permastructure (permalink format) for all posts through the plugin interface.

If you use the inbuilt tags (post_tag taxonomy), the code snippet should look as follow. I am not exactly certain if this would work out-of-box in your specific case, but it should not be difficult to adjust it:

function pm_filter_post_permastructure($permastructure, $post) {
	// Filter only 'Post' permalinks
	if(empty($post->post_type) || $post->post_type !== 'post') {
		return $permastructure;
	}
	
	// A. Articles tagged 'business' 
	if(has_term(array('business'), 'post_tag', $post)) {
		$permastructure="business/growth-and-strategy/%postname%";
	}
	// B. Articles tagged 'personal'
	else if(has_term(array('personal'), 'post_tag', $post)) {
		$permastructure="personal/growth-and-strategy/%postname%";
	}
	
	return $permastructure;
}
add_filter('permalink_manager_filter_permastructure', 'pm_filter_post_permastructure', 10, 2);

The snippet, it is supposed to dynamically overwrite the permalink settings (“Permastructures”) you have set (if certain condition is met) via the interface.

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer