Pro Tip: Master the new 'Post Thumbnail” feature in WordPress 2.9

王林
Release: 2023-08-28 18:30:02
Original
967 people have browsed it

专业提示:掌握 WordPress 2.9 中新的“后缩略图”功能

Before the release of WordPress 2.9, setting up “post-image” support for your blog was a more tedious task than it needed to be. Fortunately, this is no longer an issue. I'll show you how to set it up in this four-minute video quick tip.

Step 1: Edit the Functions.php page

// 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');
}
Copy after login

Step 2: Insert image tag into loop

In the "if have_posts()" loop, just place this code wherever you like. At this point, WordPress will insert the image tag on the page accordingly. Note that you will have access to the "wp-post-image" class, which you can then use to format/style the image.

<?php the_post_thumbnail(); ?>
Copy after login
  • Follow us on Twitter or subscribe to the Nettuts RSS Feed for the best web development tutorials on the web.

The above is the detailed content of Pro Tip: Master the new 'Post Thumbnail” feature in WordPress 2.9. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!