本文整理汇总了PHP中get_the_post_thumbnail函数的典型用法代码示例。如果您正苦于以下问题:PHP get_the_post_thumbnail函数的具体用法?PHP get_the_post_thumbnail怎么用?PHP get_the_post_thumbnail使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_the_post_thumbnail函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:closings,项目名称:closings,代码行数:28,代码来源:recentposts.php
示例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;
}
开发者ID:Atlas-Solutions-Group,项目名称:wp-menu-cart-pro,代码行数:30,代码来源:wpmenucart-jigoshop-pro.php
示例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;
}
开发者ID:MrBoy31,项目名称:helpful-intranet,代码行数:34,代码来源:ht-landing-pages.php
示例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;
}
开发者ID:barnent1,项目名称:fflcommerce,代码行数:68,代码来源:cart.php
示例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;
}
开发者ID:NathanLawrence,项目名称:Largo,代码行数:60,代码来源:largo-related-posts.php
示例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;
}
开发者ID:silversite,项目名称:silverwp,代码行数:42,代码来源:Post.php
示例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
}
开发者ID:jun200,项目名称:wordpress,代码行数:32,代码来源:functions.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;
}
开发者ID:bloemen,项目名称:success,代码行数:26,代码来源:top-category.php
示例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'];
}
}
}
开发者ID:ViewFromTheBox,项目名称:Read-More-About,代码行数:35,代码来源:read-more-about-widget.php
示例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;
}
}
开发者ID:junibrosas,项目名称:shoppingyourway,代码行数:32,代码来源:woocommerce-hook.php
示例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;
}
开发者ID:sergirams,项目名称:puentes_humanos,代码行数:26,代码来源:post_formats.php
示例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;
}
}
}
开发者ID:Cywaithaka,项目名称:WPAN,代码行数:28,代码来源:featured.php
示例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'] . '" />';
}
开发者ID:SublimeCoralie,项目名称:project-ar2,代码行数:34,代码来源:thumbnails.php
示例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;
}
开发者ID:jgacuca567,项目名称:bethel,代码行数:28,代码来源:slick-frontend.php
示例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);
}
}
开发者ID:jgonzo127,项目名称:mm-components,代码行数:33,代码来源:simple-image-content.php
示例16: widget
/**
* Front-end display of widget.
*
* @see WP_Widget::widget()
*
* @param array $args Widget arguments.
* @param array $instance Saved values from database.
*/
public function widget($args, $instance)
{
echo $args['before_widget'];
$display_title = !empty($instance['display_title']) ? $instance['display_title'] : '';
$numberofposts = !empty($instance['numberofposts']) ? absint($instance['numberofposts']) : '';
if ($display_title == 'on') {
if (!empty($instance['title'])) {
echo $args['before_title'] . apply_filters('widget_title', $instance['title']) . $args['after_title'];
}
}
$post_query_args = array('post_type' => array('post'), 'pagination' => false, 'posts_per_page' => $numberofposts, 'ignore_sticky_posts' => true, 'cache_results' => true, 'update_post_meta_cache' => true, 'update_post_term_cache' => true);
$post_query = new WP_Query($post_query_args);
if ($post_query->have_posts()) {
while ($post_query->have_posts()) {
$post_query->the_post();
global $post;
$output = '';
$output .= '<div class="widget-recent-post clearfix">';
$output .= has_post_thumbnail($post->ID) ? '<div class="recent-post-image">' : '';
$output .= has_post_thumbnail($post->ID) ? get_the_post_thumbnail($post->ID, 'illdy-widget-recent-posts') : '';
$output .= has_post_thumbnail($post->ID) ? '</div><!--/.recent-post-image-->' : '';
$output .= '<a href="' . esc_url(get_the_permalink()) . '" title="' . esc_attr(get_the_title()) . '" class="recent-post-title">' . esc_html(get_the_title()) . '</a>';
$output .= '<a href="' . esc_url(get_the_permalink()) . '" title="' . __('More...', 'illdy') . '" class="recent-post-button">' . __('More...', 'illdy') . '</a>';
$output .= '</div><!--/.widget-recent-post.clearfix-->';
echo $output;
}
} else {
echo __('No posts found.', 'illdy');
}
wp_reset_postdata();
echo $args['after_widget'];
}
开发者ID:robertoperata,项目名称:bbqverona.com,代码行数:40,代码来源:class-widget-recent-posts.php
示例17: uw_blogroll_shortcode
function uw_blogroll_shortcode($atts = array())
{
//allow pagebuilder widgets to run the shortcode, block all other posts to prevent infinite loops
if (get_post_type() == 'post' && !is_home()) {
return '';
}
$params = array_merge(array('excerpt' => 'true', 'trim' => 'false', 'image' => 'hide', 'author' => 'show', 'titletag' => 'h2', 'number' => 5), $atts);
if (!array_key_exists('numberposts', $params)) {
$params['numberposts'] = $params['number'];
}
$posts = get_posts($params);
foreach ($posts as $post) {
if (!stripos($post->post_content, '[blogroll')) {
//to prevent infinite loops in pagebuilder widgets
$postID = $post->ID;
$link = get_permalink($postID);
if (in_array($params['excerpt'], array('show', 'true'))) {
$excerpt = strlen($post->post_excerpt) > 0 ? $post->post_excerpt : apply_filters('widget_text', $post->post_content);
if (in_array($params['trim'], array('show', 'true'))) {
$excerpt = wp_trim_words($excerpt);
}
$excerpt = wpautop($excerpt);
//using apply_filters('the_content', $excerpt) causes an infinite loop
if (in_array($params['image'], array('show', 'true'))) {
$image = get_the_post_thumbnail($postID, 'thumbnail', array('style' => 'float:left;padding-right:10px;'));
$class = 'class="pull-left"';
}
}
$author = $params['author'] === 'show' ? '<p class="author-info">' . get_the_author_meta('display_name', $post->post_author) . '</p>' : '';
$postDate = get_the_time(get_option('date_format'), $postID);
$html .= "<li {$class}>{$image}<span><p class=\"date\">{$postDate}</p><" . $params['titletag'] . "><a href=\"{$link}\">{$post->post_title}</a></" . $params['titletag'] . ">{$author}{$excerpt}</span></li>";
}
}
return "<ul class=\"shortcode-blogroll\">{$html}</ul>";
}
开发者ID:uw-sop,项目名称:htdocs,代码行数:35,代码来源:custom-shortcodes.php
示例18: owl_column
/**
* Add custom column contents in administration
* @param string $columnName
*/
public function owl_column($columnName)
{
global $post;
if ($columnName == 'thumbnail') {
echo edit_post_link(get_the_post_thumbnail($post->ID, 'thumbnail'), null, null, $post->ID);
}
}
开发者ID:evaristocolomby,项目名称:owl-carousel,代码行数:11,代码来源:class-post-type.php
示例19: end_el
function end_el(&$output, $item, $depth = 0, $args = array())
{
if ($depth == 0 && $item->object == 'category') {
$output .= "<div class='subcat'>";
for ($i = 0; $i < count($item->children); $i++) {
$child = $item->children[$i];
$output .= "<div class='" . ($i === 0 ? 'active' : '') . "' id='mn-latest-" . $child->ID . "'>";
//$output .="<h5>".$child->title."</h5>";
$output .= "<ul id='mn-latest-" . $child->ID . "'>";
if ($child->object == 'category') {
$r = new WP_Query(apply_filters('widget_posts_args', array('posts_per_page' => 5, 'no_found_rows' => true, 'post_status' => 'publish', 'cat' => $child->object_id)));
if ($r->have_posts()) {
while ($r->have_posts()) {
$r->the_post();
$output .= "<li ";
if (has_post_thumbnail()) {
$output .= "class='has-thumbnail' ";
}
$output .= "><div class='subcat-thumbnail'><a href='" . get_permalink() . "' title='" . get_the_title() . "'>" . get_the_post_thumbnail(get_the_ID(), array(40, 40)) . "</a></div><div class='subcat-title'><a href='" . get_permalink() . "' title='" . get_the_title() . "'> " . get_the_title() . "</a><span> - " . dw_human_time_diff(get_the_time('U'), current_time('timestamp')) . "</span></div></li>";
}
// Reset the global $the_post as this query will have stomped on it
wp_reset_postdata();
}
}
$output .= "</ul>";
$output .= "<a href='" . $child->url . "' title='" . $child->attr_title . "'>View all</a>";
$output .= "</div>";
}
$output .= "</div> \n</div>\n";
} else {
}
$output .= "</li>\n";
}
开发者ID:aromis,项目名称:dw-focus,代码行数:33,代码来源:mega-menu.php
示例20: _get_post_thumbnail
/**
* Get the thumbnail image for a post's image
*
* Attempts to find the URL for the thumbnail size of an image attached to a Post
*
* @param int $post_id The ID of the WordPress Post
* @param string $image_url The URL of the image to get a thumbnail for
*
* @global $wpdb
*
* @uses current_theme_supports()
* @uses get_the_post_thumbnail()
* @uses wpdb::prepare()
* @uses wpdb::get_row()
* @uses wp_get_attachment_image()
* @uses wp_upload_dir()
*
* @return string
*/
private function _get_post_thumbnail($post_id, $image_url)
{
global $wpdb;
$thumbnail_src = $image_url;
$thumbnail_html = "";
// Use the post thumbnail if possible
if (current_theme_supports('post-thumbnails')) {
$thumbnail_html = get_the_post_thumbnail($post_id, 'thumbnail');
}
// Process for a thumbnail version of the background image
$url_parts = parse_url($image_url);
// Get array of URL parts of the image
$wp_upload_dir = wp_upload_dir();
// Get array of URL parts of the upload directory
$relative_upload_base = str_replace(ABSPATH, "", str_replace($wp_upload_dir['subdir'], "", $wp_upload_dir['path']));
if (isset($url_parts['host']) && $url_parts['host'] == $_SERVER['HTTP_HOST'] && strpos($url_parts['path'], "/" . $relative_upload_base) !== false) {
$image_url_original = preg_replace("/\\-[0-9]+x[0-9]+\\.(jpeg|jpg|gif|png|bmp)\$/", ".\$1", $image_url);
$post = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->posts} WHERE guid = %s", $image_url_original));
if (!empty($post)) {
$thumbnail_html = wp_get_attachment_image($post->ID, 'thumbnail');
}
}
if (!empty($thumbnail_html)) {
$matches = array();
preg_match("/ src\\=\"([^\"]+)\"/", $thumbnail_html, $matches);
if (count($matches) > 1) {
$thumbnail_src = $matches[1];
}
}
return $thumbnail_src;
}
开发者ID:danaiser,项目名称:hollandLawns,代码行数:50,代码来源:source.php
注:本文中的get_the_post_thumbnail函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论