وردپرس نسخه 3,0+مرجع توابع مورد استفاده در کد نویسی پوسته
Post Thumbnail Tags
Get Post Thumbnail IDget_post_thumnbnail_id();
If a thumbnail is set - Returns the ID of the Thumbnail attached to the post. If no such attachment exists, the function returns null (empty value).
<?php get_post_thumnbnail_id($id); ?>
$id
Integer
(Optional) Post ID. Default: none.
Get The Post Thumbnailget_the_post_thumnbnail();
Gets Post Thumbnail as set in post's or page's edit screen. Thumbnail images are given class "attachment-thumbnail".
<?php get_post_thumnbnail_id($id, $size, $attr); ?>
$id
Integer
(Optional) Post ID. Default: none.
$size
String
(Optional) Image size. Default: 'post-thumbnail'
$attr
String/Array
(Optional) Query string or array of attributes. See wp_get_attachment_image.
<?php $default_attr = array( | ||
'src' | => | $src, |
'class' | => | "attachment-$size", |
'alt' | => | trim(strip_tags( $attachment->post_excerpt )), |
'title' | => | trim(strip_tags( $attachment->post_title )), |
); | ||
?> |
Has Post Thumbnailhas_post_thumbnail();
Returns a boolean if post has an image attached (true) or not (false). Note: To enable post thumbnails, the current theme must include add_theme_support( 'post-thumbnails' ); in its functions.php file.
<?php has_post_thumbnail($post_id); ?>
$post_id
Integer
(Optional) Post ID. Default: 'ID', the post ID.
The Post Thumbnailthe_post_thumbnail();
Display Post Thumbnail as set in post's edit screen. Thumbnail images are given class "attachment-thumbnail". To enable post thumbnails, the current theme must include add_theme_support( 'post-thumbnails' ); in its functions.php file.
<?php the_post_thumbnail($size, $attr); ?>
$size
String/Array
(Optional) Image size. Default: 'post-thumbnail', which theme sets using set_post_thumbnail_size($width, $height, $crop_flag);. Either a string keyword(thumbnail, medium, large or full) or a 2-item array representing width and height in pixels, e.g. array(32,32).
$attr
Array
(Optional) Array of attribute/value pairs. For details, search source for the function that the_post_thumbnail relies on: wp_get_attachment_image. Default: none.