How do I correct my function for a custom field that displays a link?
-
I’ve really wrestled with this. For each blog post, I’m going to ask a question, which will display as a link. I’ve managed to get the question to print as a link, but it’s not grabbing the link value. Instead, it’s using the current blog page as the URL. It’s also not opening a new tab.
add_action('genesis_entry_content', 'the_question'); function the_question($post_id) { the_meta(); $question = get_post_meta('question'); $link = get_post_meta('link'); echo '<div class="moose-question">'; echo <a href="<?php echo $link; ?>" target="_blank"><?php $question; ?></a>; echo '</div>'; }
I’m wondering a couple of things.
First, am I registering custom fields properly by using
the_meta();
? Without it, this function resulted in an error message. I’m seeing different ways people are activating custom fields. This is just one of them. I’m not sure if this is the best option.Second, the function breaks my design and results in two other functions not working properly.
I’ve done quite a bit of research on this and would appreciate your suggestions. Thank you!
- The topic ‘How do I correct my function for a custom field that displays a link?’ is closed to new replies.