porton
porton

Reputation: 5803

Attaching images to WordPress posts

I need to make it easy for users to attach a single image to a WordPress post. Now it seems that the user needs first add his image to media library and only then link it within his post manually entering the image URL. That's bad.

I also need to display these images in a sidebar with post announces. How to do that?

Upvotes: 0

Views: 185

Answers (2)

5wpthemes
5wpthemes

Reputation: 181

Add this line in your function.php file.

add_theme_support('post-thumbnails');

To display the post image in sidebar you can use

get_post_thumbnail_id();

or a custom function.

Upvotes: 0

Alex
Alex

Reputation: 46

You need to enable post thumbnails in your functions.php which will then enable the featured image meta fox. From there they can attach an image. In your template you then can call the post_thumbnail function to retrieve the image.

http://codex.wordpress.org/Function_Reference/add_theme_support

http://codex.wordpress.org/Function_Reference/the_post_thumbnail

Upvotes: 3

Related Questions