Add Links To wp_get_post_terms
-
I have added the following function in my theme
function sell_post_code(){ $sec_level_arg = array( 'style' => 'none', 'hierarchical' => 1, 'orderby' => 'name', 'order' => 'ASC', 'hide_empty' => 0, 'title_li' => '', 'depth' => '2', 'taxonomy' => 'zip-code', 'echo' => 0 ); $third_level_arg = array( 'style' => 'none', 'orderby' => 'name', 'order' => 'ASC', 'hide_empty' => 0, 'title_li' => '', 'depth' => '3', 'child_of'=>'', 'taxonomy' => 'zip-code', 'echo' => 0 ); $sec_level_arg_exploaded = explode('<br />',wp_list_categories($sec_level_arg)); $third_level_arg_exploaded = explode('<br />',wp_list_categories($third_level_arg)); $places = array_diff($third_level_arg_exploaded,$sec_level_arg_exploaded ); asort($places); $test = implode('',$places); $regexp = "<a\s[^>]*href=(\"??)([^\" >]*?)\\1[^>]*>(.*)<\/a>"; if(preg_match_all("/$regexp/siU", $test, $matches, PREG_SET_ORDER)) { foreach($matches as $match) { // create new arra name->link for later sorting //$c[] = array('name' => $match[3], 'link' => $match[2]); $c[] = $match[3]; } } $args = array('orderby' => 'name', 'order' => 'ASC', 'fields' => 'all'); $terms = wp_get_post_terms( get_the_ID(),"zip-code", $args ); foreach($terms as $t){ $ct[] = $t->name; } $result_array = array_intersect($c, $ct); $dee_output = implode(', ',$result_array); return $dee_output; } add_shortcode('sell_post_code','sell_post_code');
The function displays the current post terms properly, but I would like them to include the link to the taxonomy terms page.
Any idea how to add links to the terms?
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Add Links To wp_get_post_terms’ is closed to new replies.