当前位置: 首页>>代码示例>>PHP>>正文


PHP get_the_post_thumbnail_url函数代码示例

本文整理汇总了PHP中get_the_post_thumbnail_url函数的典型用法代码示例。如果您正苦于以下问题:PHP get_the_post_thumbnail_url函数的具体用法?PHP get_the_post_thumbnail_url怎么用?PHP get_the_post_thumbnail_url使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了get_the_post_thumbnail_url函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: opengraph

    public function opengraph()
    {
        $tags = [];
        if (is_singular()) {
            $tags['og:title'] = get_the_title();
        } elseif (is_archive()) {
            $tags['og:title'] = get_the_archive_title();
        }
        if (is_singular()) {
            $tags['og:description'] = get_the_excerpt();
        }
        if (is_singular()) {
            $tags['og:url'] = get_permalink();
        } elseif (is_tax()) {
            $tags['og:url'] = get_term_link(get_queried_object(), get_queried_object()->taxonomy);
        }
        if (is_singular() && has_post_thumbnail()) {
            $tags['og:image'] = get_the_post_thumbnail_url('full');
        }
        $tags = wp_parse_args($tags, ['og:type' => 'website', 'og:title' => get_bloginfo('name'), 'og:description' => get_bloginfo('description'), 'og:url' => home_url('/'), 'og:image' => get_site_icon_url()]);
        $tags = array_filter($tags);
        $tags = apply_filters('opengraph_tags', $tags);
        foreach ($tags as $property => $content) {
            printf('
			<meta property="%s" content="%s">', esc_attr($property), esc_attr($content));
        }
    }
开发者ID:tomjal,项目名称:feelingrestful-theme,代码行数:27,代码来源:class-opengraph.php

示例2: wpb_latest_sticky

function wpb_latest_sticky()
{
    /* Get all sticky posts */
    $sticky = get_option('sticky_posts');
    /* Sort the stickies with the newest ones at the top */
    rsort($sticky);
    /* Get the 5 newest stickies (change 5 for a different number) */
    $sticky = array_slice($sticky, 0, 1);
    /* Query sticky posts */
    $the_query = new WP_Query(array('post__in' => $sticky, 'ignore_sticky_posts' => 1));
    // The Loop
    $arr = array();
    if ($the_query->have_posts()) {
        while ($the_query->have_posts()) {
            $the_query->the_post();
            $arr['permlink'] = get_permalink("", "", false);
            $arr['title'] = get_the_title("", "", false);
            $arr['excerpt'] = get_the_excerpt("", "", false);
            $arr['img_url'] = get_the_post_thumbnail_url();
        }
    } else {
        // no posts found
        $arr['excerpt'] = $arr['title'] = $arr['permlink'] = $arr["img_url"] = "404 not found any featured post ! :( ";
    }
    /* Restore original Post Data */
    wp_reset_postdata();
    return $arr;
}
开发者ID:duongcuong96,项目名称:my-wp-themes,代码行数:28,代码来源:functions.php

示例3: get_css

    /**
     * @return string Inline CSS
     * @since 0.0.1-dev
     */
    private function get_css()
    {
        if (has_post_thumbnail() && !post_password_required()) {
            $thumb = esc_url(get_the_post_thumbnail_url(null, 'push7ssb-sbz-thumbnail'));
        } elseif (has_site_icon()) {
            $thumb = esc_url(get_site_icon_url());
        } else {
            $thumb = '';
        }
        return <<<EOI
.push7-sb-sbz-with-thumb {
\tbackground-image: url({$thumb});
}
.push7-sb-sbz-with-thumb-subscribe {
\tbackground-color: rgba(43,43,43, 0.7);
\tcolor: #ffffff;
}
@media only screen and (min-width : 415px) {
\t.push7-sb-sbz-with-thumb-thumbnail {
\t\tbackground-image: url({$thumb});
\t}
\t.push7-sb-sbz-with-thumb-subscribe {
\t\tbackground-color: rgba(43,43,43, 1);
\t}
}
EOI;
    }
开发者ID:hinaloe,项目名称:push7-subscribe-button,代码行数:31,代码来源:class.withthumb.php

示例4: wcj_get_product_image_url

 /**
  * wcj_get_product_image_url.
  *
  * @version 2.5.7
  * @since   2.5.7
  * @todo    placeholder
  */
 function wcj_get_product_image_url($product_id, $image_size = 'shop_thumbnail')
 {
     if (has_post_thumbnail($product_id)) {
         $image_url = get_the_post_thumbnail_url($product_id, $image_size);
     } elseif (($parent_id = wp_get_post_parent_id($product_id)) && has_post_thumbnail($parent_id)) {
         $image_url = get_the_post_thumbnail_url($parent_id, $image_size);
     } else {
         $image_url = '';
     }
     return $image_url;
 }
开发者ID:algoritmika,项目名称:woocommerce-jetpack,代码行数:18,代码来源:wcj-functions.php

示例5: widget

 function widget($args, $instance)
 {
     /* Our variables from the widget settings. */
     $title = apply_filters('widget_title', isset($instance['title']) ? $instance['title'] : __(' ', 'bookyourtravel'));
     extract($args);
     echo $before_widget;
     $url = get_post_meta($title, '_location', true);
     $img = get_the_post_thumbnail_url($title, 'large');
     echo "<a target='_blank' href='" . $url . "'><img  src='" . $img . "'></a>";
     /* After widget (defined by themes). */
     echo $after_widget;
 }
开发者ID:boutitinizar,项目名称:bati-men,代码行数:12,代码来源:widget_mnb_banner.php

示例6: get_thumbnail

 /**
  * Get thumbnail image url
  *
  * @param null|\WP_Post $_post Post data object.
  *
  * @return string
  */
 public static function get_thumbnail($_post = null)
 {
     $thumb = apply_filters(VA_SOCIALBUZZ_PREFIX . 'default_thumbnail', 'none');
     if (empty($_post)) {
         global $post;
         $_post = $post;
     }
     if (!empty($_post) && has_post_thumbnail($_post) && !post_password_required($_post)) {
         $thumb = get_the_post_thumbnail_url($_post, VA_SOCIALBUZZ_PREFIX . 'thumbnail');
     } elseif ('none' === $thumb && has_header_image()) {
         $thumb = get_header_image();
     } elseif ('none' === $thumb && has_site_icon()) {
         $thumb = get_site_icon_url();
     }
     return $thumb;
 }
开发者ID:visualive,项目名称:va-social-buzz,代码行数:23,代码来源:trait-functions.php

示例7: __construct

 function __construct($wp_post)
 {
     $this->id = (int) $wp_post->ID;
     $this->type = $wp_post->post_type;
     $this->slug = $wp_post->post_name;
     $this->url = get_permalink($this->id);
     $this->status = $wp_post->post_status;
     $this->title = get_the_title($this->id);
     $this->title_plain = strip_tags(@$this->title);
     $this->excerpt = apply_filters('the_excerpt', get_the_excerpt($wp_post->ID));
     $this->date = get_the_time($wp_post->ID);
     $this->modified = $wp_post->post_modified;
     $this->categories = get_the_category($this->id);
     $tags = get_the_tags($this->id);
     $this->tags = $tags ? $tags : array();
     $this->author = get_the_author($wp_post->ID);
     $this->comment_count = (int) $wp_post->comment_count;
     $this->comment_status = $wp_post->comment_status;
     $this->thumbnail = get_the_post_thumbnail_url($wp_post->ID);
     $this->custom_fields = get_post_custom($this->id);
 }
开发者ID:neekey,项目名称:wordpress-simple-api,代码行数:21,代码来源:post.php

示例8: init

 /**
  * @internal
  * @param false|object $coauthor co-author object
  */
 protected function init($coauthor = false)
 {
     $this->id = $coauthor->ID;
     $this->first_name = $coauthor->first_name;
     $this->last_name = $coauthor->last_name;
     $this->user_nicename = $coauthor->user_nicename;
     $this->description = $coauthor->description;
     /**
      * @property string name
      */
     $this->display_name = $coauthor->display_name;
     $this->_link = get_author_posts_url(null, $coauthor->user_nicename);
     // 96 is the default wordpress avatar size
     $avatar_url = get_the_post_thumbnail_url($this->id, 96);
     if (CoAuthorsPlus::$prefer_gravatar || !$avatar_url) {
         $avatar_url = get_avatar_url($coauthor->user_email);
     }
     if ($avatar_url) {
         $this->avatar = new \Timber\Image($avatar_url);
     }
 }
开发者ID:jarednova,项目名称:timber,代码行数:25,代码来源:CoAuthorsPlusUser.php

示例9: the_ID

?>

<article id="post-<?php 
the_ID();
?>
" <?php 
post_class();
?>
>
	<div class="entry-wrapper">
		<?php 
if (!is_single() && has_post_thumbnail()) {
    ?>
			<div class="entry-image">
				<?php 
    $post_image_thumbnail_url = get_the_post_thumbnail_url(get_the_ID(), 'full');
    $post_image_thumbnail = aq_resize($post_image_thumbnail_url, 310, '', false, false);
    ?>
				<a class="post-feature-image" href="<?php 
    the_permalink();
    ?>
">
					<img class="img-responsive" src="<?php 
    echo $post_image_thumbnail[0];
    ?>
"
					     width="<?php 
    echo $post_image_thumbnail[1];
    ?>
"
					     height="<?php 
开发者ID:dungtd91,项目名称:bones,代码行数:31,代码来源:content.php

示例10: the_post_thumbnail_url

/**
 * Display the post thumbnail URL.
 *
 * @since 4.4.0
 *
 * @param string|array $size Optional. Image size to use. Accepts any valid image size,
 *                           or an array of width and height values in pixels (in that order).
 *                           Default 'post-thumbnail'.
 */
function the_post_thumbnail_url($size = 'post-thumbnail')
{
    $url = get_the_post_thumbnail_url(null, $size);
    if ($url) {
        echo esc_url($url);
    }
}
开发者ID:AndreyLanko,项目名称:perevorot-prozorro-wp,代码行数:16,代码来源:post-thumbnail-template.php

示例11: foreach

</section>

<?php 
$features = $fields['features'];
if ($features[0] != 0) {
    /* if there are features */
    ?>

<section id="home-features" class="row full-width">
	<?php 
    $f = 1;
    foreach ($features as $featureObj) {
        $feature = $featureObj['feature'];
        $id = $feature->ID;
        $featureFields = get_fields($id);
        $imageSrc = get_the_post_thumbnail_url($id, 'home-feature');
        $title = $feature->post_title;
        $subtitle = $featureFields['subtitle'];
        $excerpt = $feature->post_excerpt;
        $link = get_the_permalink($id);
        ?>
			
			<div class="feature <?php 
        if ($f % 2 == 0) {
            echo 'reverse';
        }
        ?>
 animate-in">
				
				<div class="image animate-element <?php 
        if ($f % 2 == 0) {
开发者ID:SirDingus,项目名称:andyducett,代码行数:31,代码来源:index.php

示例12: if

            </div>
            <div class="content-body">

		    	<?php if (have_posts()): while (have_posts()) : the_post(); ?>
					<div class="body-container">
						<h1><?php the_title(); ?></h1>
						<?php the_content(); // Dynamic Content ?>
						<div class="pagination">

							<?php $nextPost = get_next_post(true);?>
								<div class="previous" style="background-image:url('<?php echo get_the_post_thumbnail_url($nextPost->ID); ?>');">
									<?php next_post_link('%link', '<span>Previous Story</span><p>%title</p>'); ?>
								</div>
							

							<div class="home"><h3><a href="/news/">Back to news home</a></h3></div> 
							
							<?php $prevPost = get_previous_post(true);?>
							<div class="next" style="background-image:url('<?php echo get_the_post_thumbnail_url($prevPost->ID); ?>');"><?php previous_post_link('%link', '<span>Next Story</span><p>%title</p>'); ?>
							</div>
							
						</div>
					</div>

		    	<?php endwhile; ?>

				<?php endif; ?>

			</div>

开发者ID:jknowles94,项目名称:Work-examples,代码行数:29,代码来源:single-news.php

示例13: jkl_post_nav

    /**
     * Display navigation to next/previous post when applicable.
     *
     * Improve the post_nav() with post thumbnails. Help from this
     * @link: http://www.measureddesigns.com/adding-previous-next-post-wordpress-post/
     * @link: http://wpsites.net/web-design/add-featured-images-to-previous-next-post-nav-links/
     */
    function jkl_post_nav()
    {
        // Don't print empty markup if there's nowhere to navigate.
        $previous = is_attachment() ? get_post(get_post()->post_parent) : get_adjacent_post(false, '', true);
        $next = get_adjacent_post(false, '', false);
        $prevID = $previous ? $previous->ID : '';
        $nextID = $next ? $next->ID : '';
        if (!$next && !$previous) {
            return;
        }
        ?>
	<nav class="navigation post-navigation clear" role="navigation">
		<h2 class="screen-reader-text"><?php 
        _e('Post navigation', 'jkl');
        ?>
</h2>

                <div class="nav-links">
                    <?php 
        // My custom code below FIRST, then _s code
        // PREVIOUS POST LINK
        if (!empty($previous)) {
            ?>
                    <div class="nav-previous">
                        <a href="<?php 
            echo get_permalink($prevID);
            ?>
" rel="prev">

                            <?php 
            if (has_post_thumbnail($prevID) && has_post_thumbnail($nextID)) {
                $prev_thumb = get_the_post_thumbnail_url($prevID, 'medium');
                $prev_thumb = $prev_thumb ? $prev_thumb : get_header_image();
                ?>
                                    <div class="post-nav-thumb" style="background-image: url( <?php 
                echo $prev_thumb;
                ?>
 )">
                                        <!-- Placeholder for image -->
                                    </div>
                            <?php 
            }
            ?>

                            <span class="meta-nav" aria-hidden="true"><?php 
            _e('Previously', 'jkl');
            ?>
</span>
                            <span class="screen-reader-text"><?php 
            _e('Previous Post', 'jkl');
            ?>
</span>
                            <span class="post-title"><?php 
            echo $previous->post_title;
            ?>
</span>

                        </a>
                    </div>
                    <?php 
        }
        // NEXT POST LINK
        if (!empty($next)) {
            ?>
                    <div class="nav-next">
                        <a href="<?php 
            echo get_permalink($nextID);
            ?>
" rel="next">

                            <?php 
            if (has_post_thumbnail($prevID) && has_post_thumbnail($nextID)) {
                $next_thumb = get_the_post_thumbnail_url($nextID, 'medium');
                $next_thumb = $next_thumb ? $next_thumb : get_header_image();
                ?>
                                    <div class="post-nav-thumb"style="background-image: url( <?php 
                echo $next_thumb;
                ?>
 )">
                                        <!-- Placeholder for image -->
                                    </div>
                            <?php 
            }
            ?>

                            <span class="meta-nav" aria-hidden="true"><?php 
            _e('Next time', 'jkl');
            ?>
</span>
                            <span class="screen-reader-text"><?php 
            _e('Next Post', 'jkl');
            ?>
</span>
//.........这里部分代码省略.........
开发者ID:jekkilekki,项目名称:theme-jkl,代码行数:101,代码来源:template-tags.php

示例14: while

    //                            endwhile;
    ?>
                                            
                            </ul>-->
                                
                            <ul class="testimonial-quotes">
                            <?php 
    while ($query->have_posts()) {
        $query->the_post();
        if ('' != get_the_post_thumbnail()) {
            ?>
                                    <li class="quote quote-<?php 
            echo get_the_ID();
            ?>
" data-thumb="<?php 
            echo get_the_post_thumbnail_url($post, 'medium');
            ?>
">
                                    <?php 
            get_template_part('components/features/frontpage/front', 'testimonials');
            ?>
                                    </li>
                                <?php 
        }
    }
    ?>
                            </ul>    
                            </div>
                        </section><!-- #testimonials -->
                        
                    <?php 
开发者ID:jekkilekki,项目名称:theme-jin,代码行数:31,代码来源:frontpage-portfolio.php

示例15: while



    <?php 
if (have_posts()) {
    while (have_posts()) {
        the_post();
        ?>

            <!--BEGIN .hentry-->
            <?php 
        echo '<div class="services">';
        echo '<div class="service">
                        <h1 class="service-title">' . get_the_title() . '</h1>
                        <hr/>
                        <div class="service-content">
                            <img class="service-img" src="' . get_the_post_thumbnail_url() . '">
                            <p class="service-desc">' . get_the_content() . '</p>
                        </div>
                      </div>';
        echo '</div>';
        ?>
            <?php 
    }
}
?>

    <!--END #primary .hfeed-->
</div>

<?php 
get_footer();
开发者ID:prkirby,项目名称:AbsolutePressure,代码行数:29,代码来源:single-services_offered.php


注:本文中的get_the_post_thumbnail_url函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。