I want to display custom text widgets for each post in the sidebar?

Ideally I am looking for two text boxes added to the ‘Add new post’ admin page, and the data from those two boxes be displayed in the sidebar when viewing the post page. So the sidebar displays the data belong to the post…. Two widgets for each post. Possible?

Thanks a ton in advance!

Related posts

Leave a Reply

1 comment

  1. You should take a look into creating custom meta boxes to display the text fields in the admin & then save that data as post meta. There are many tutorials available online for this

    Once you have the information, you can put a get_post_meta call in your theme’s sidebar.php file & display the data there directly. If you want it in widget format, you’ll have to create a custom widget to display the meta information. Again there are many tutorials available online for this.

    When displaying the info you can add a condition like

    if(is_single() && 'post' == get_post_type())
        echo get_post_meta(get_the_ID(), 'custom-field-key', true);