I created a taxonomy called animal and a term meta field called horse.

I created a function in my functios.php file to make it easier to display the data.

Here is my code:

function regular_info_page() {
                $terms = get_the_terms($post->ID, 'animal');
                $result = "";
                if (is_array($terms) || is_object($terms)){
                foreach ($terms as $term) {
                    $term_id = $term->term_id;
                    $result .= get_term_meta( $term_id, 
'horse', true );
                return $result;

The meta field horse holds a link, and I would like to display the link on my page, but instead of it opening the link, it just reloads the current page.

Here is the code I placed on the page:

<p><a href="<?php regular_info_page(); ?>">For more info on this Bracha, click here.</a></p>

Any ideas?

2 Answers 2


You’re not echoing the result, it’s just returning which isn’t output to the page. You should be able to change return $result; into echo $result; and have it display.

Just be aware that as you have your code now, it’s not going to return or echo a proper link.

My guess is you could use something like is found at the link below to do what you need.



@ericb For some reason I can't add a comment, but to me it looks like he put the function code (return $result) in his functions.php file, and not on the page, so there is no reason for him to change it to echo $result. If anything the echo should be in the second piece of code he posted, but it should still display on the page without the echo. Just my 2 cents.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.