本文整理汇总了PHP中get_the_post_thumbnail函数的典型用法代码示例。如果您正苦于以下问题:PHP get_the_post_thumbnail函数的具体用法?PHP get_the_post_thumbnail怎么用?PHP get_the_post_thumbnail使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_the_post_thumbnail函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: widget
function widget($args, $instance)
{
global $post;
extract($args, EXTR_SKIP);
echo $before_widget;
$title = empty($instance['title']) ? __('Recent Posts', 'lan-thinkupthemes') : apply_filters('widget_title', $instance['title']);
if (!empty($title)) {
echo $before_title . $title . $after_title;
}
$posts = new WP_Query('orderby=date&posts_per_page=' . $instance['postcount'] . '');
while ($posts->have_posts()) {
$posts->the_post();
// Insert post date if needed.
if ($instance['postdate'] == 'on') {
$date_input = '<a href="' . get_permalink() . '" class="date">' . get_the_date('M j, Y') . '</a>';
}
// HTML output
echo '<div class="recent-posts">';
if (has_post_thumbnail() and $instance['imageswitch'] == 'on') {
echo '<div class="image">', '<a href="' . get_permalink() . '" title="' . get_the_title() . '">' . get_the_post_thumbnail($post->ID, array(65, 65)) . '<div class="image-overlay"></div></a>', '</div>', '<div class="main">', '<a href="' . get_permalink() . '">' . get_the_title() . '</a>', $date_input, '</div>';
} else {
echo '<div class="main">', '<a href="' . get_permalink() . '">' . get_the_title() . '</a>', $date_input, '</div>';
}
echo '</div>';
}
wp_reset_query();
echo $after_widget;
}
示例2: submenu_items
/**
* Add Menu Cart to menu
*
* @return menu items including cart
*/
public function submenu_items()
{
$get_cart = jigoshop_cart::get_cart();
$submenu_items = '';
//see jigoshop/widgets/cart.php
if (count($get_cart) > 0) {
foreach ($get_cart as $cart_item_key => $values) {
$_product = $values['data'];
if ($_product->exists() && $values['quantity'] > 0) {
$item_thumbnail = has_post_thumbnail($_product->id) ? get_the_post_thumbnail($_product->id, 'shop_tiny') : jigoshop_get_image_placeholder('shop_tiny');
$item_name = $_product->get_title();
// Not used: Displays variations and cart item meta
$item_meta = jigoshop_cart::get_item_data($values);
$item_quantity = esc_attr($values['quantity']);
$item_price = $_product->get_price_html();
// Item permalink
$item_permalink = esc_attr(get_permalink($_product->id));
$submenu_items[] = array('item_thumbnail' => $item_thumbnail, 'item_name' => $item_name, 'item_quantity' => $item_quantity, 'item_price' => $item_price, 'item_permalink' => $item_permalink);
}
}
} else {
$submenu_items = '';
}
return $submenu_items;
}
示例3: hp_landingpages_shortcode
function hp_landingpages_shortcode($atts, $content)
{
//get any attributes that may have been passed; override defaults
$opts = shortcode_atts(array('id' => '', 'exclude' => '', 'type' => ''), $atts);
// get child pages
global $wp_query;
$id = $opts['id'] == "" ? $wp_query->post->ID : $opts['id'];
$children = get_pages("child_of=" . $id . "&parent=" . $id . "&hierarchical=0&exclude=" . $opts['exclude'] . "&posts_per_page=-1&post_type=page&sort_column=menu_order&sort_order=ASC");
foreach ((array) $children as $c) {
if ($opts['type'] == 'list') {
$output .= "<li><a href='" . get_permalink($c->ID) . "'>" . get_the_title($c->ID) . "</a></li>";
} else {
$excerpt = '';
if ($c->post_excerpt) {
$excerpt = $c->post_excerpt;
} else {
if (strlen($c->post_content) > 200) {
$excerpt = substr(strip_tags($c->post_content), 0, 200) . "…";
} elseif ($c->post_content == "" || $c->post_content == 0) {
$excerpt = "";
} else {
$excerpt = strip_tags($c->post_content);
}
}
$output .= "\n\t\t\t<div class='htlandingpage clearfix'>\n\t\t\t " . get_the_post_thumbnail($c->ID, "listingthumb", "class=listingthumb") . "\n\t\t\t <h2><a href='" . get_permalink($c->ID) . "'>" . get_the_title($c->ID) . "</a></h2>\n\t\t\t <p>" . $excerpt . "</p>\n\t\t\t</div>\n\t\t\t";
}
}
if ($opts['type'] == 'list') {
$html = "<ul>" . $output . "</li>";
} else {
$html = "<div class='htlandingpageblock'>" . $output . "</div>";
}
return $html;
}
示例4: widget
/**
* Widget
* Display the widget in the sidebar
* Save output to the cache if empty
*
* @param array sidebar arguments
* @param array instance
*/
public function widget($args, $instance)
{
// Hide widget if page is the cart or checkout
if (is_cart() || is_checkout()) {
return false;
}
extract($args);
// Set the widget title
$title = apply_filters('widget_title', $instance['title'] ? $instance['title'] : __('Cart', 'fflcommerce'), $instance, $this->id_base);
// Print the widget wrapper & title
echo $before_widget;
if ($title) {
echo $before_title . $title . $after_title;
}
// Get the contents of the cart
$cart_contents = fflcommerce_cart::$cart_contents;
// If there are items in the cart print out a list of products
if (!empty($cart_contents)) {
// Open the list
echo '<ul class="cart_list">';
foreach ($cart_contents as $key => $value) {
// Get product instance
$_product = $value['data'];
if ($_product->exists() && $value['quantity'] > 0) {
echo '<li>';
// Print the product image & title with a link to the permalink
echo '<a href="' . esc_attr(get_permalink($_product->id)) . '" title="' . esc_attr($_product->get_title()) . '">';
// Print the product thumbnail image if exists else display placeholder
echo has_post_thumbnail($_product->id) ? get_the_post_thumbnail($_product->id, 'shop_tiny') : fflcommerce_get_image_placeholder('shop_tiny');
// Print the product title
echo '<span class="js_widget_product_title">' . $_product->get_title() . '</span>';
echo '</a>';
// Displays variations and cart item meta
echo fflcommerce_cart::get_item_data($value);
// Print the quantity & price per product
echo '<span class="js_widget_product_price">' . $value['quantity'] . ' × ' . $_product->get_price_html() . '</span>';
echo '</li>';
}
}
echo '</ul>';
// Close the list
// Print the cart total
echo '<p class="total"><strong>';
echo __('Subtotal', 'fflcommerce');
echo ':</strong> ' . fflcommerce_price($this->total_cart_items());
echo '</p>';
do_action('fflcommerce_widget_cart_before_buttons');
// Print view cart & checkout buttons
$view_cart_button_label = isset($instance['view_cart_button']) ? $instance['view_cart_button'] : __('View Cart →', 'fflcommerce');
$checkout_button_label = isset($instance['checkout_button']) ? $instance['checkout_button'] : __('Checkout →', 'fflcommerce');
echo '<p class="buttons">';
echo '<a href="' . esc_attr(fflcommerce_cart::get_cart_url()) . '" class="button">' . __($view_cart_button_label, 'fflcommerce') . '</a>';
echo '<a href="' . esc_attr(fflcommerce_cart::get_checkout_url()) . '" class="button checkout">' . __($checkout_button_label, 'fflcommerce') . '</a>';
echo '</p>';
} else {
echo '<span class="empty">' . __('No products in the cart.', 'fflcommerce') . '</span>';
}
// Print closing widget wrapper
echo $after_widget;
}
示例5: widget
function widget($args, $instance)
{
global $post;
// Preserve global $post
$preserve = $post;
extract($args);
// only useful on post pages
if (!is_single()) {
return;
}
$title = apply_filters('widget_title', empty($instance['title']) ? __('Read Next', 'largo') : $instance['title'], $instance, $this->id_base);
echo $before_widget;
if ($title) {
echo $before_title . $title . $after_title;
}
$related = new Largo_Related($instance['qty']);
//get the related posts
$rel_posts = new WP_Query(array('post__in' => $related->ids(), 'nopaging' => 1, 'posts_per_page' => $instance['qty'], 'ignore_sticky_posts' => 1));
if ($rel_posts->have_posts()) {
echo '<ul class="related">';
while ($rel_posts->have_posts()) {
$rel_posts->the_post();
echo '<li>';
echo '<a href="' . get_permalink() . '"/>' . get_the_post_thumbnail(get_the_ID(), 'thumbnail', array('class' => 'alignleft')) . '</a>';
?>
<h4><a href="<?php
the_permalink();
?>
" title="Read: <?php
esc_attr(the_title('', '', FALSE));
?>
"><?php
the_title();
?>
</a></h4>
<h5 class="byline">
<span class="by-author"><?php
largo_byline(true, true);
?>
</span>
<time class="entry-date updated dtstamp pubdate" datetime="<?php
echo esc_attr(get_the_date('c'));
?>
"><?php
largo_time();
?>
</time>
</h5>
<?php
// post excerpt/summary
largo_excerpt(get_the_ID(), 2, false, '', true);
echo '</li>';
}
echo "</ul>";
}
echo $after_widget;
// Restore global $post
wp_reset_postdata();
$post = $preserve;
}
示例6: getRecent
/**
* Latest blog posts
*
* @param int $limit post display limit
*
* @param string $thumbnail_size
*
* @return array
*/
public static function getRecent($limit = 10, $thumbnail_size = 'thumbnail')
{
$args = array('numberposts' => $limit, 'offset' => 0, 'category' => 0, 'orderby' => 'post_date', 'order' => 'DESC', 'include' => '', 'exclude' => '', 'meta_key' => '', 'meta_value' => '', 'post_type' => 'post', 'post_status' => 'draft, publish, future, pending', 'suppress_filters' => true);
$array_out = array();
$recent_posts = \get_posts(\wp_parse_args($args));
/*$like_bool = Option::get_theme_option( 'blog_list_like' );
if ( $like_bool === '1' ) {
$PostLike = \SilverWp\Ajax\PostLike::getInstance();
}*/
foreach ($recent_posts as $key => $recent) {
\setup_postdata($recent);
$post_id = $recent->ID;
//$array_out[ $key ] = $recent;
$array_out[$key]['ID'] = $post_id;
$array_out[$key]['post_title'] = \get_the_title($post_id);
$array_out[$key]['url'] = \get_the_permalink($post_id);
$array_out[$key]['post_author'] = \get_the_author();
$array_out[$key]['post_date'] = \get_the_date('', $post_id);
$array_out[$key]['post_date_utc'] = \get_the_time('c', $post_id);
//$array_out[ $key ]['post_like'] = ($like_bool === '1') ? $PostLike->getPostLikeCount($post_id) : '';
$array_out[$key]['post_comment_count'] = $recent->comment_count;
if (strpos($recent->post_content, '<!--more-->') || empty($recent->post_excerpt)) {
$array_out[$key]['post_excerpt'] = \get_the_excerpt();
} else {
$array_out[$key]['post_excerpt'] = $recent->post_excerpt;
}
$array_out[$key]['image_html'] = \get_the_post_thumbnail($post_id, $thumbnail_size);
// Thumbnail
$array_out[$key]['categories'] = self::getTaxonomy($post_id);
}
\wp_reset_postdata();
return $array_out;
}
示例7: family_banner
function family_banner()
{
?>
<div class="banner">
<div class="wrap">
<?php
if (is_front_page()) {
family_get_header_image();
} elseif (!is_front_page() && get_theme_mod('family_header_home')) {
echo '';
} else {
// get title
$id = get_option('page_for_posts');
if ('posts' == get_option('show_on_front') && (is_day() || is_month() || is_year() || is_tag() || is_category() || is_singular('post') || is_home())) {
family_get_header_image();
} elseif (is_home() || is_singular('post')) {
if (has_post_thumbnail($id)) {
echo get_the_post_thumbnail($id, 'full');
} else {
family_get_header_image();
}
} elseif (has_post_thumbnail() && is_singular('page')) {
the_post_thumbnail();
} else {
family_get_header_image();
}
}
?>
</div><!-- .wrap -->
</div><!-- .banner -->
<?php
}
示例8: show_category
function show_category($cid = 1)
{
$args = array('showposts' => 4, 'cat' => $cid, 'orderby' => 'post_date', 'order' => 'desc');
query_posts($args);
global $the_post;
$category = '';
while (have_posts()) {
the_post();
$cat = get_the_category(get_the_ID());
$link = get_permalink(get_the_ID());
$src = get_the_post_thumbnail(get_the_ID(), 'index_thumb');
$c_name = $cat[0]->name;
$title = get_the_title();
echo $category .= <<<EOF
<div class="box">
<a href="{$link}">
<div class="boximg">{$src}</div>
<div class="category">{$c_name}</div>
<p>{$title}</p>
</a>
</div>
EOF;
}
wp_reset_query();
return $category;
}
示例9: widget
/**
* Outputs the HTML of the widget
*
* @param array $args
*
* @param array $instance
*
* @since 1.4
*/
public function widget($args, $instance)
{
extract($args);
if (is_single()) {
$fields = get_post_meta(get_the_ID(), 'read_more_links', true);
if ($fields) {
echo $args['before_widget'];
echo $args['before_title'] . apply_filters('widget_title', $instance['title']) . $args['after_title'];
echo '<aside class="read-more-about-widget">';
foreach ($fields as $field) {
echo '<div class="story">';
if ($field['read_more_about_in_ex'] == 'internal') {
if (has_post_thumbnail($field['read_more_about_internal_link'])) {
echo '<div class="photo"><a href="' . get_the_permalink($field['read_more_about_internal_link']) . '">' . get_the_post_thumbnail($field['read_more_about_internal_link'], 'read-more') . '</a></div>';
}
echo '<h3 class="story-title"><a href="' . get_the_permalink($field['read_more_about_internal_link']) . '">' . get_the_title($field['read_more_about_internal_link']) . '</a></h3>';
} else {
echo '<h3 class="story-title"><a href="' . $field['read_more_about_link'] . '" target="_blank">' . $field['read_more_about_external_title'] . '</a></h3>';
}
echo '</div>';
}
echo '</aside>';
echo $args['after_widget'];
}
}
}
示例10: ya_product_thumbnail
function ya_product_thumbnail($size = 'shop_catalog', $placeholder_width = 0, $placeholder_height = 0)
{
global $post;
$html = '';
$id = get_the_ID();
$gallery = get_post_meta($id, '_product_image_gallery', true);
$attachment_image = '';
if (!empty($gallery)) {
$gallery = explode(',', $gallery);
$first_image_id = $gallery[0];
$attachment_image = wp_get_attachment_image($first_image_id, $size, false, array('class' => 'hover-image back'));
}
$image = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), '');
if (has_post_thumbnail()) {
if ($attachment_image) {
$html .= '<div class="product-thumb-hover">';
$html .= get_the_post_thumbnail($post->ID, $size) ? get_the_post_thumbnail($post->ID, $size) : '<img src="' . get_template_directory_uri() . '/assets/img/placeholder/' . $size . '.png" alt="No thumb">';
$html .= $attachment_image;
$html .= '</div>';
/* quickview */
$nonce = wp_create_nonce("ya_quickviewproduct_nonce");
$link = admin_url('admin-ajax.php?ajax=true&action=ya_quickviewproduct&post_id=' . $post->ID . '&nonce=' . $nonce);
$html .= '<a href="' . $link . '" data-fancybox-type="ajax" class="group fancybox fancybox.ajax">' . apply_filters('out_of_stock_add_to_cart_text', __('Quick View ', 'yatheme')) . '</a>';
} else {
$html .= get_the_post_thumbnail($post->ID, $size) ? get_the_post_thumbnail($post->ID, $size) : '<img src="' . get_template_directory_uri() . '/assets/img/placeholder/' . $size . '.png" alt="No thumb">';
}
return $html;
} else {
$html .= '<img src="' . get_template_directory_uri() . '/assets/img/placeholder/' . $size . '.png" alt="No thumb">';
return $html;
}
}
示例11: us_post_format_image_preview
function us_post_format_image_preview($thumbnail_size = 'blog-grid', &$content = null)
{
global $post;
$thumbnail = get_the_post_thumbnail(get_the_ID(), $thumbnail_size);
$preview = "";
if (empty($content)) {
$content = $post->post_content;
}
if (!$thumbnail) {
preg_match("%^(https?(?://([^/?#]*))?([^?#]*?\\.(?:jpg|gif|png)))%", $content, $image_link_result);
if (!empty($image_link_result[0])) {
$preview = '<img src="' . $image_link_result[0] . '" alt="">';
$content = str_replace($image_link_result[0], "", $content);
} else {
preg_match("%^<img.+?>%", $content, $image_tag_result);
if (!empty($image_tag_result[0])) {
$preview = $image_tag_result[0];
$content = str_replace($image_tag_result[0], "", $content);
}
}
} else {
$preview = $thumbnail;
}
$post->post_content = $content;
return $preview;
}
示例12: x_featured_image
function x_featured_image($cropped = '')
{
$stack = x_get_stack();
$fullwidth = in_array('x-full-width-active', get_body_class()) ? true : false;
if (has_post_thumbnail()) {
if ($cropped == 'cropped') {
if ($fullwidth) {
$thumb = get_the_post_thumbnail(NULL, 'entry-' . $stack . '-cropped-fullwidth', NULL);
} else {
$thumb = get_the_post_thumbnail(NULL, 'entry-' . $stack . '-cropped', NULL);
}
} else {
if ($fullwidth) {
$thumb = get_the_post_thumbnail(NULL, 'entry-' . $stack . '-fullwidth', NULL);
} else {
$thumb = get_the_post_thumbnail(NULL, 'entry-' . $stack, NULL);
}
}
switch (is_singular()) {
case true:
printf('<div class="entry-thumb">%s</div>', $thumb);
break;
case false:
printf('<a href="%1$s" class="entry-thumb" title="%2$s">%3$s</a>', esc_url(get_permalink()), esc_attr(sprintf(__('Permalink to: "%s"', '__x__'), the_title_attribute('echo=0'))), $thumb);
break;
}
}
}
示例13: ar2_get_thumbnail
/**
* Helper function to grab and display thumbnail from specified post
* @since 1.4.0
*/
function ar2_get_thumbnail($size = 'thumbnail', $id = NULL, $attr = array())
{
global $post, $ar2_image_sizes;
if ($post) {
$id = $post->ID;
}
if (!key_exists('alt', $attr)) {
$attr['alt'] = esc_attr(get_the_excerpt());
}
if (!key_exists('title', $attr)) {
$attr['title'] = esc_attr(get_the_title());
}
if (has_post_thumbnail($id)) {
return get_the_post_thumbnail($id, $size, $attr);
} else {
// Could it be an attachment?
if ($post->post_type == 'attachment') {
return wp_get_attachment_image($id, $size, false, $attr);
}
// Use first thumbnail if auto thumbs is enabled.
if (ar2_get_theme_option('auto_thumbs')) {
$img_id = ar2_get_first_post_image_id();
if ($img_id) {
return wp_get_attachment_image($img_id, $size, false, $attr);
}
}
}
// Return empty thumbnail if all else fails.
return '<img src="' . get_template_directory_uri() . '/images/empty_thumbnail.gif" alt="' . $attr['alt'] . '" title="' . $attr['title'] . '" />';
}
示例14: slickc_load_images
function slickc_load_images($attributes)
{
$args = array('post_type' => 'slickc', 'posts_per_page' => '-1', 'orderby' => $attributes['orderby'], 'order' => $attributes['order']);
if (!empty($attributes['category'])) {
$args['carousel_category'] = $attributes['category'];
}
if (!empty($attributes['id'])) {
$args['p'] = $attributes['id'];
}
$loop = new WP_Query($args);
$images = array();
$output = '';
while ($loop->have_posts()) {
$loop->the_post();
$image = get_the_post_thumbnail(get_the_ID(), 'full');
if (!empty($image)) {
$post_id = get_the_ID();
$title = get_the_title();
$content = get_the_excerpt();
$image_src = wp_get_attachment_image_src(get_post_thumbnail_id(), 'full');
$image_src = $image_src[0];
$url = get_post_meta(get_the_ID(), 'slickc_image_url');
$url_openblank = get_post_meta(get_the_ID(), 'slickc_image_url_openblank');
$images[] = array('post_id' => $post_id, 'title' => $title, 'content' => $content, 'image' => $image, 'img_src' => $image_src, 'url' => esc_url($url[0]), 'open_blank' => $url_openblank[0]);
}
}
return $images;
}
示例15: mm_posts_output_custom_post_image_simple_image_content
/**
* Custom Image Output for Simple Image & Content template.
*/
function mm_posts_output_custom_post_image_simple_image_content($post, $context, $args)
{
$custom_output = apply_filters('mm_posts_post_image', '', $post, $context, $args);
if ('' !== $custom_output) {
echo $custom_output;
return;
}
// Default to using the 'post-thumbnail' size.
if ('' !== $args['featured_image_size']) {
$image_size = esc_attr($args['featured_image_size']);
} else {
$image_size = 'post-thumbnail';
}
// Check for existing featured image
if (has_post_thumbnail($post->ID)) {
$image_tag = get_the_post_thumbnail($post->ID, $image_size);
} else {
$fallback_image = $args['fallback_image'];
// Support the fallback image
if (is_numeric($fallback_image)) {
$image_tag = wp_get_attachment_image($fallback_image, $image_size);
}
}
// Output image with/without link
if (mm_true_or_false($args['link_title'])) {
printf('<div class="entry-image"><a href="%s">%s</a></div>', get_permalink($post->ID), $image_tag);
} else {
printf('<div class="entry-image">%s</div>', $image_tag);
}
}