将图像附加到WordPress的帖子

时间:2012-03-01 17:11:32

标签: wordpress

我需要让用户轻松将单个图像附加到WordPress帖子。现在看来,用户首先需要将他的图像添加到媒体库,然后才能在他的帖子中手动输入图像URL。那很糟糕。

我还需要在带有发布通知的侧栏中显示这些图像。怎么做?

2 个答案:

答案 0 :(得分:3)

您需要在functions.php中启用后缩略图,然后启用精选图像元狐狸。从那里他们可以附加图像。在模板中,您可以调用post_thumbnail函数来检索图像。

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

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

答案 1 :(得分:0)

在function.php文件中添加此行。

add_theme_support('post-thumbnails');

要在侧边栏中显示帖子图片,您可以使用

get_post_thumbnail_id();

或自定义功能。