• Hello all,

    I’m hoping someone can help me. I have a custom meta field in my back end post editor that allows for someone to enter a URL. I am pulling this into the loop to display on the bottom of my posts on the main page using get_post_meta.

    I now want to display that link on the single page posts also. Preferably with a widget. There are a few different widgets that allow php, but I’m not sure if they are able to do what I want. Does anyone know of a way to accomplish this?

    Here is a snippet of the code that I am using in the loop page:

    <?php while (have_posts()) : the_post();
    
    //Post Link
    $post_link = get_post_meta($post->ID, 'soy_post_link', true);
    
    ?>
    
    <a href="<?php echo $post_link; ?>">Visit Source</a>

    Thanks in advance,
    Keith

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi Keith,

    Using “PHP Code Widget” you can do this with such code:

    <?php
    if(is_single())
    {
      global $post;
      $post_link = get_post_meta($post->ID, 'soy_post_link', true);
    
      echo "<a href=\"$post_link\">Visit Source</a>";
    }
    ?>

    Let me know if you need something more.

    Thread Starter kfawcett

    (@kfawcett)

    Thank you!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Pulling custom meta into widget’ is closed to new replies.