Hey – so i hacked your code – feel free to use it. Basically I created a new term you can add to get the first term from a custom taxonomy. There is the skeleton to make it do more, but you can at least get 1 term and make it the path.
add this after line 106
$customdir = (strpos($customdir, '%post_taxonomy_%') !== false)? cud_find_and_replace_taxonomies($post_id,$customdir): $customdir;
and then after the function cud_get_categories_name, add
#/--------------- HACK - START ----------------------------\
function cud_find_and_replace_taxonomies($post_id,$customdir){
//$prefix = "%post_taxonomy_%";
//$postfix = "%_post_taxonomy%";
//str_replace($prefix.$postfix,"josh-test01", $customdir);
return cud_find_and_replace_taxonomies_helper($post_id,$customdir);
}
function cud_find_and_replace_taxonomies_helper($post_id,$customdir){
$prefix = "%post_taxonomy_%";
$postfix = "%_post_taxonomy%";
$prefix_length = strlen($prefix);
$postfix_length = strlen($postfix);
$prefix_index = strpos($customdir,$prefix);
$postfix_index = strpos($customdir,$postfix);
if(($prefix_index !== false) && ($postfix_index !== false)){
$str_left = substr($customdir,0,$prefix_index);
$postfix_ending_index = $postfix_index+$postfix_length;
$str_right_length = strlen($customdir)-$postfix_ending_index;
$str_right = substr($customdir,$postfix_ending_index,$str_right_length);
$prefix_ending_index = $prefix_index+$prefix_length;
$taxonomyName = substr($customdir,$prefix_index+$prefix_length,$postfix_index-$prefix_ending_index);
return cud_find_and_replace_taxonomies_helper($post_id,$str_left.cud_get_taxonomy($post_id,$taxonomyName).$str_right);
}
/*
clear all unused with placeholders
*/
else{
return str_replace($prefix,"-cud-pr-", str_replace($postfix,"-cud-po-", $customdir));
}
}
function cud_get_taxonomy($post_id,$taxonomyName){
return cud_get_taxonomies($post_id,$taxonomyName,1);
}
function cud_get_taxonomies($post_id,$taxonomyName,$count){
$terms_array = get_the_terms($post_id,$taxonomyName);
if(is_array($terms_array)){
$terms = array();
if($count == -1){
foreach($terms_array as $term_object){
$terms[] = $term_object->slug;
}
}else{
for ( $counter = 0; $counter < count($terms_array) && $counter < $count; $counter += 1) {
$terms[] = $terms_array[$counter]->slug;
}
}
return implode('-', $terms);
}else{
return "_".$taxonomyName;
}
}
#\--------------- HACK - END ----------------------------/
Then in cud_option_page, add the following to $placeholder
'post_taxonomy_%%_post_taxonomy' => __('The post\'s first term in the specified taxonomy. Place taxonomy name between the two delimiters', 'cud'),
Enjoy
Please contact me if you want the php file.