• I love your sideposts widget!

    I hoping you could help me with the code I’d need to add to display a custom field. Specifically, I will have a custom field for a URL. In the custom Sideposts template I’d create, I want add the following line at the bottom of the sidepost that says:

    Go to webpage

    That would be hperlinked to the URL in the custom field.

    Can anyone provide the code I’d need for this?

Viewing 1 replies (of 1 total)
  • Well, imagine you name your custom field: ‘go_url’

    To get it from a post, just use the get_post_meta() function:

    $go_url = get_post_meta(get_the_ID(), 'go_url', true);

    And display the custom field content anywhere you want. Example: two fields: the site_name and site_url, you could set something like this:

    $post_id = get_the_ID();
    echo '<p>View also: <a href="'
        . get_post_meta($post_id, 'site_url', true) .
        '">' . get_post_meta($post_id, 'site_name', true)
        . '</a></p>';

    Hope this helps.

Viewing 1 replies (of 1 total)
  • The topic ‘[Plugin: SidePosts Widget]’ is closed to new replies.