taxonomies
-
Trying to make a function which put taxonomy and terms on posting.
It should not have a hyperlink, looking in the codex made it first easy..copy/paste/edit and done but how to do it with multiple taxonomies and terms? Seldom is shown (in codex) how to do for multiple issues/options so I am stuck. Any help would be nice.
function my_function($content) { if (is_single()) { global $post, $site, $article; $terms = get_the_terms($post->ID, 'site'); $terms = get_the_terms($post->ID, 'article') ; if ( $terms && ! is_wp_error( $terms ) ) : $site = array(); $article = array(); foreach ( $terms as $term ) { $site_links[] = $term->name ; $article_links[] = $term->name ; } $site = join( ", ", $site_links ); $article = join( ", ", $article_links ); ?> <p> Site: <strong><?php echo $site; ?></strong><br /> Article: <strong><?php echo $article; ?></strong> </p> <?php endif; return $content; } else { return $content; } } add_filter('the_content', 'my_function');
It shows only outcome for Article (on both), it skips Site, what am I missing or doing wrong?
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘taxonomies’ is closed to new replies.