• I don’t really get how to use custom fields.

    I have a custom field “link” for every post with a different value. All I want to do is use the value to generate the link text.

    IE: <a href="url">value of custom field "link"</a>

    Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)
  • this should work

    <a href="url"><?php echo get_post_meta( $post_id, 'link', true ); ?></a>

    Purely off the top of my head:

    <?php $link = get_post_meta( $post_id, 'link' );?>
    <a href="https://foobar.com/"><?php echo $link;?></a>

    i am trying something similar with custom fields, however, one of my custom fields contains a link. i was wondering how to access that link on click

    <li<?php if ($thisPage=="Page One")
          echo " id=\"currentpage\""; ?>>
          <a href="#">link to ebook</a></li>
        <li<?php if ($thisPage=="Page Two")
          echo " id=\"currentpage\""; ?>>
          <a href="#">watch video</a></li>
        <li<?php if ($thisPage=="Page Three")
          echo " id=\"currentpage\""; ?>>
          <a href="#">view report</a></li>

    so when the user clicks the button for “watch video” it will access the link contained in the custom field… any ideas?

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Custom field value as link’ is closed to new replies.