Support » Fixing WordPress » Post data in the sidebar

Viewing 5 replies - 1 through 5 (of 5 total)
  • I would use a Custom Field to hold the URL. When you create a Post, you would add the Custom Field to it and give it the value of the link for that post. Then, in the sidebar, retrieve the custom field for the post and use the value in the link.

    Right – Can I access that value from outside the loop though (my sidebar is outside of the loop)?

    If you have the post ID, both get_post_meta() and get_post_custom() will work.

    Thanks for your help vtxyzzy, I’ve got it to work!

    The next step for me is to get the social links for email, facebook and twitter to work. Any idea where I might start?

    The solution for those who come after me:
    I entered a custom field for the post (name: url, value: URL I want to be displayed outside the loop). I then placed the following in my theme where I want the URL to be:

    <?php $url = get_post_meta($post->ID, 'url', true); echo $url; ?>

    Glad you got that part to work. For the social links, I suggest you start a new thread because many people look for a thread with no replies. If you do that, please use the dropdown at top right to mark this topic ‘Resolved’.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Post data in the sidebar’ is closed to new replies.