在 WordPress 2.9 发布之前,为您的博客设置“后图像”支持是一项比实际需要的任务更加繁琐的任务。幸运的是,这不再是问题。我将在这个四分钟的视频快速提示中向您展示如何进行设置。
// Enable support for post-thumbnails add_theme_support('post-thumbnails'); // If we want to ensure that we only call this function if // the user is working with WP 2.9 or higher, // let's instead make sure that the function exists first if ( function_exists('add_theme_support') ) { add_theme_support('post-thumbnails'); }
在“if have_posts()”循环中,只需将这段代码放置在您喜欢的任何位置即可。此时,WordPress 将相应地在页面上插入图像标签。请注意,您将有权访问“wp-post-image”类,然后您可以使用该类来设置图像的格式/样式。
<?php the_post_thumbnail(); ?>
以上就是专业提示:掌握 WordPress 2.9 中新的“后缩略图”功能的详细内容,更多请关注php中文网其它相关文章!
全网最新最细最实用WPS零基础入门到精通全套教程!带你真正掌握WPS办公! 内含Excel基础操作、函数设计、数据透视表等
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号