本文整理汇总了PHP中MultiPostThumbnails::has_post_thumbnail方法的典型用法代码示例。如果您正苦于以下问题:PHP MultiPostThumbnails::has_post_thumbnail方法的具体用法?PHP MultiPostThumbnails::has_post_thumbnail怎么用?PHP MultiPostThumbnails::has_post_thumbnail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MultiPostThumbnails
的用法示例。
在下文中一共展示了MultiPostThumbnails::has_post_thumbnail方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: custom_image_directory
function custom_image_directory($path, $args)
{
if (class_exists('MultiPostThumbnails') && MultiPostThumbnails::has_post_thumbnail('post', 'twitter-image', $args['id'])) {
// get the image for Twitter
$imgid = MultiPostThumbnails::get_post_thumbnail_id('post', 'twitter-image', $args['id']);
$path = wp_get_attachment_url($imgid);
// Using amazon S3? Replace your S3 path with local path
$path = str_replace('http://brewbound-images.s3.amazonaws.com/', 'c:\\inetpub\\wp-brewbound\\', $path);
$path = str_replace('/', '\\', $path);
}
return $path;
}
示例2: nectar_recent_posts
//.........这里部分代码省略.........
}
}
// endif for if there's a video
}
// endif for 3.6
} else {
if (get_post_format() == 'audio') {
?>
<div class="audio-wrap">
<?php
if ($wp_version < "3.6") {
nectar_audio($post->ID);
} else {
$audio_mp3 = get_post_meta($post->ID, '_nectar_audio_mp3', true);
$audio_ogg = get_post_meta($post->ID, '_nectar_audio_ogg', true);
if (!empty($audio_ogg) || !empty($audio_mp3)) {
$audio_output = '[audio ';
if (!empty($audio_mp3)) {
$audio_output .= 'mp3="' . $audio_mp3 . '" ';
}
if (!empty($audio_ogg)) {
$audio_output .= 'ogg="' . $audio_ogg . '"';
}
$audio_output .= ']';
echo do_shortcode($audio_output);
}
}
?>
</div><!--/audio-wrap-->
<?php
} else {
if (get_post_format() == 'gallery') {
if ($wp_version < "3.6") {
if (MultiPostThumbnails::has_post_thumbnail(get_post_type(), 'second-slide')) {
nectar_gallery($post->ID);
} else {
if (has_post_thumbnail()) {
echo get_the_post_thumbnail($post->ID, 'portfolio-thumb', array('title' => ''));
}
}
} else {
$gallery_ids = grab_ids_from_gallery();
?>
<div class="flex-gallery">
<ul class="slides">
<?php
foreach ($gallery_ids as $image_id) {
echo '<li>' . wp_get_attachment_image($image_id, 'portfolio-thumb', false) . '</li>';
}
?>
</ul>
</div><!--/gallery-->
<?php
}
} else {
if (has_post_thumbnail()) {
echo '<a href="' . get_permalink() . '">' . get_the_post_thumbnail($post->ID, 'portfolio-thumb', array('title' => '')) . '</a>';
}
}
}
}
?>
<div class="post-header">
示例3: has_post_thumbnail
/**
* Check to see if a custom post thumbnail has been added to a post.
*
* @param string $type Type of added thumbnail to check for.
*
* @return bool True if thumbnail exists. False if not.
*/
public function has_post_thumbnail($type)
{
if (class_exists('MultiPostThumbnails')) {
return MultiPostThumbnails::has_post_thumbnail(get_post_type(), $type);
}
return false;
}
示例4: trim
?>
" alt="<?php
echo $caption;
?>
" />
<figcaption><?php
echo $caption;
?>
</figcaption>
</figure>
<?php
}
?>
<?php
if (MultiPostThumbnails::has_post_thumbnail(get_post_type(), 'image3')) {
?>
<?php
$post_thumbnail_id = MultiPostThumbnails::get_post_thumbnail_id(get_post_type(), 'image3', get_queried_object_id());
$post_thumbnail_post = get_post($post_thumbnail_id);
$caption = trim(strip_tags($post_thumbnail_post->post_excerpt));
$caption = esc_html($caption);
?>
<figure class="extra-image">
<img src="<?php
echo $imgURL = MultiPostThumbnails::get_post_thumbnail_url(get_post_type(), 'image3', NULL, 'large');
?>
" alt="<?php
echo $caption;
?>
" />
示例5: json_encode
?>
<div class="step-2 container-fluid block" data-details="<?php
echo json_encode($custom_fields);
?>
">
<div class="row pt12">
<div class="container">
<div class="col-md-5 text-center">
<?php
$our_queried_page = get_page_by_title($custom_fields['original_entry_number'][0], 'OBJECT', $custom_fields['taxonomy-tier'][0]);
?>
<?php
echo get_the_post_thumbnail($our_queried_page->ID, 'large');
?>
<?php
if (class_exists('MultiPostThumbnails') && MultiPostThumbnails::has_post_thumbnail($our_queried_page->post_type, $our_queried_page->post_type . '-secondary', $our_queried_page->ID)) {
?>
<?php
MultiPostThumbnails::the_post_thumbnail($our_queried_page->post_type, $our_queried_page->post_type . '-secondary', $our_queried_page->ID, 'large');
?>
<?php
}
?>
</div>
<div class="col-lg-7 mt6 description">
<h2 class="uppercase mb2 pb2"><?php
the_title();
?>
</h2>
<h4 class="uppercase mb2 pb2">by <?php
echo $custom_fields['student_name'] ? $custom_fields['student_name'][0] : $custom_fields['company_name'][0];
示例6: kite_get_secondary_background_image
function kite_get_secondary_background_image($default)
{
if (class_exists('MultiPostThumbnails')) {
if (MultiPostThumbnails::has_post_thumbnail(get_post_type(), 'background-image')) {
return MultiPostThumbnails::get_post_thumbnail_url(get_post_type(), 'background-image');
} else {
return $default;
}
} else {
return $default;
}
}
示例7: nectar_gallery
function nectar_gallery($postid)
{
if (class_exists('MultiPostThumbnails')) {
?>
<div class="flex-gallery">
<ul class="slides">
<?php
if (has_post_thumbnail()) {
echo '<li>' . get_the_post_thumbnail($postid, 'full', array('title' => '')) . '</li>';
}
?>
<?php
if (MultiPostThumbnails::has_post_thumbnail(get_post_type(), 'second-slide')) {
echo '<li>' . MultiPostThumbnails::get_the_post_thumbnail(get_post_type(), 'second-slide') . '</li>';
}
if (MultiPostThumbnails::has_post_thumbnail(get_post_type(), 'third-slide')) {
echo '<li>' . MultiPostThumbnails::get_the_post_thumbnail(get_post_type(), 'third-slide') . '</li>';
}
if (MultiPostThumbnails::has_post_thumbnail(get_post_type(), 'fourth-slide')) {
echo '<li>' . MultiPostThumbnails::get_the_post_thumbnail(get_post_type(), 'fourth-slide') . '</li>';
}
if (MultiPostThumbnails::has_post_thumbnail(get_post_type(), 'fifth-slide')) {
echo '<li>' . MultiPostThumbnails::get_the_post_thumbnail(get_post_type(), 'fifth-slide') . '</li>';
}
if (MultiPostThumbnails::has_post_thumbnail(get_post_type(), 'sixth-slide')) {
echo '<li>' . MultiPostThumbnails::get_the_post_thumbnail(get_post_type(), 'sixth-slide') . '</li>';
}
?>
</ul>
</div><!--/gallery-->
<?php
}
}
示例8: tdr_top_choices_table
function tdr_top_choices_table($args)
{
$defaults = array('number_to_show' => 3, 'number_to_query' => 3, 'offer_cat_terms' => get_terms('offer-category', array('fields' => 'ids')), 'rank_meta_key' => '');
$args = wp_parse_args($args, $defaults);
extract($args, EXTR_SKIP);
/* Set up the Query */
/* Taxonomy for the Query
* ***************************************************************/
// Set up the taxonomy
$offer_cat_args = array(array('taxonomy' => 'offer-category', 'field' => 'id', 'terms' => $offer_cat_terms));
/* Create the query
* ***************************************************************/
$basic_query = new WP_Query(array('tax_query' => $offer_cat_args, 'post_type' => 'tdr_product', 'posts_per_page' => (int) $number_to_query, 'order' => 'ASC', 'orderby' => 'meta_value_num', 'meta_key' => 'thunder_plugin_products_rank'));
// If a Rank Key is defined, reorder the Products
if (!empty($rank_meta_key)) {
global $tdr_rank_key;
$tdr_rank_key = $rank_meta_key;
usort(&$basic_query->{'posts'}, 'tdr_sort_by_offer_category_rank');
$basic_query->rewind_posts();
}
// Update to only show the $number_to_show
$basic_query->post_count = $number_to_show;
$returner = '<div class="row">';
$returner .= '<div class="span">';
// Set up tdr_product
$product = new Thunder_Plugin_Products();
while ($basic_query->have_posts()) {
$basic_query->the_post();
// Get the ID for the Rating Bar, this determines how the stars appear
$internal_rating = floatval($product->get_the_internal_rating());
if ($internal_rating < 2.2) {
$internal_rating_id = 'two_zero';
} elseif ($internal_rating < 2.7) {
$internal_rating_id = 'two_five';
} elseif ($internal_rating < 3.2) {
$internal_rating_id = 'three_zero';
} elseif ($internal_rating < 3.7) {
$internal_rating_id = 'three_five';
} elseif ($internal_rating < 4.2) {
$internal_rating_id = 'four_zero';
} elseif ($internal_rating < 4.7) {
$internal_rating_id = 'four_five';
} elseif ($internal_rating >= 4.7) {
$internal_rating_id = 'five_zero';
} else {
$internal_rating_id = $internal_rating;
}
// Force display of non-significant digits for the internal rating
$internal_rating = sprintf("%1.1f", $internal_rating);
// Output a row for this Product, and get its name
$returner .= '<div class="row"><div class="span4" style="border-top: 1px solid #eee; padding: 10px 0;">';
$product_name = $product->get_the_affiliate_name();
// Get the logo, and set up link
add_image_size('our_top_choices_thumb', 120, 30);
$review_link = get_permalink();
$attr['alt'] = $product_name . ' Reviews';
$attr['title'] = $product_name . ' Reviews';
if (class_exists('MultiPostThumbnails') && MultiPostThumbnails::has_post_thumbnail('tdr_product', 'thumbnail-affiliate-logo')) {
$affiliate_img = MultiPostThumbnails::get_the_post_thumbnail('tdr_product', 'thumbnail-affiliate-logo', NULL, 'our_top_choices_thumb', $attr);
}
$returner .= "<div class='our_top_logos'>";
$returner .= "<a href='{$review_link}'>";
$returner .= $affiliate_img;
$returner .= '</a>';
$returner .= "</div><!-- end .our_top_logos -->";
$returner .= "<div class='our_top_ratings' style=''>";
$returner .= "<div id='{$internal_rating_id}' class='rating-bar' style='position: relative; left: 5px;'></div>";
$returner .= "<span style='font-size: 24px; font-weight: bold; line-height: 24px; '>{$internal_rating}</span>" . " <span class='review-link'>(<a href='{$review_link}' style=''>Review</a>)</span>";
$returner .= "</div>";
$returner .= "<div class='our_top_visit' style=''>";
$product_id = $product->get_the_id();
$jump_page_url = get_home_url() . "/visit?site={$product_id}&t=sidebar";
$returner .= "<a target=_blank' href='{$jump_page_url}'><span style='font-size:10px;'>▶</span> Visit Site</a>";
$returner .= "</div>";
$returner .= '</div><!-- end .span --></div><!-- end .row -->';
}
$returner .= "</div><!-- end .span -->";
$returner .= "</div><!-- end .row -->";
$returner .= '<div class="read_more_articles">';
$offer_category_permalink = get_home_url() . '/reviews';
$returner .= "<a href='{$offer_category_permalink}' id='review_page_link'>+ View All Reviews</a>";
$returner .= '</div><!-- end .read_more_articles -->';
return $returner;
}
示例9: is_page
?>
<section class="hero <?php
echo is_page('writings') || is_page('showcase') ? 'hero--small' : '';
?>
">
<?php
if (is_front_page()) {
echo '<div class="hero__gradient"></div>';
}
$postType = get_post_type($id);
if (class_exists('MultiPostThumbnails') && MultiPostThumbnails::has_post_thumbnail($postType, 'hero-image', $id) && !is_archive()) {
$hero = MultiPostThumbnails::get_post_thumbnail_url($postType, 'hero-image', $id);
if (MultiPostThumbnails::has_post_thumbnail($postType, 'mobile-hero-image', $id)) {
$mobileHero = MultiPostThumbnails::get_post_thumbnail_url($postType, 'mobile-hero-image', $id);
}
if (MultiPostThumbnails::has_post_thumbnail($postType, 'medium-hero-image', $id)) {
$mediumHero = MultiPostThumbnails::get_post_thumbnail_url($postType, 'medium-hero-image', $id);
}
?>
<picture>
<source media="(min-width: 80em)" srcset="<?php
echo $hero;
?>
">
<source media="(min-width: 64em)" srcset="<?php
echo $mediumHero;
?>
">
<source media="(max-width: 64em)" srcset="<?php
echo $mobileHero;
?>
示例10: the_permalink
if ($i % 3 == 0) {
echo "first-col";
}
?>
">
<div class="row">
<div class="img-wrap">
<a href="<?php
the_permalink();
?>
" title="<?php
the_title();
?>
">
<?php
if (class_exists('MultiPostThumbnails') && MultiPostThumbnails::has_post_thumbnail('post', 'home-image')) {
MultiPostThumbnails::the_post_thumbnail('post', 'home-image', NULL, 'full', NULL, false);
} else {
?>
<img src="<?php
bloginfo('template_directory');
?>
/assets/img/jkc-no-image-288x140.jpg" alt="<?php
the_title();
?>
" draggable="false">
<?php
}
?>
</a>
</div>
示例11: get_post_thumbnail_id
$hasImage = false;
if (has_post_thumbnail($section->ID)) {
$hasImage = true;
$thumbnail_id = get_post_thumbnail_id($section->ID);
$image = wp_get_attachment_url($thumbnail_id);
}
//get other feature images
if (class_exists('MultiPostThumbnails')) {
$i = 1;
$j = 1;
$imagefe = array();
$imagefe[0] = $image;
while ($i <= 9) {
$image_name = 'feature-image-' . $i;
// sets image name as feature-image-1, feature-image-2 etc.
if (MultiPostThumbnails::has_post_thumbnail('page_section', $image_name, $section->ID)) {
$image_id = MultiPostThumbnails::get_post_thumbnail_id('page_section', $image_name, $section->ID);
$imagefe[$j] = wp_get_attachment_url($image_id);
$j++;
}
$i++;
}
}
$format = get_post_meta($section->ID, 'section_format', true);
$format = esc_attr($format);
$theme = get_post_meta($section->ID, 'section_theme', true);
$theme = esc_attr($theme);
//1=>dark 2=>intense 3=>medium 4=>light
?>
<div class="pageSection theme<?php
echo $theme;
示例12: render_card_meta
/**
* Renders card meta fields in wp_head
* @return string
*/
static function render_card_meta()
{
if (!is_singular(array_keys(self::$post_types))) {
return;
}
$vpm_group = get_post_type() . '_twitter_card';
if (!($card_type = get_vpm_value($vpm_group, 'twitter_card_type', get_queried_object_id()))) {
return;
}
$card_data = array('card' => $card_type, 'title' => self::get_the_title(), 'description' => self::get_the_description());
switch ($card_type) {
case 'gallery':
$images = array();
for ($i = 1; $i <= 4; $i++) {
if (MultiPostThumbnails::has_post_thumbnail(get_post_type(), 'twitter-card-gallery-image-' . $i, get_queried_object_id())) {
$images['image' . ($i - 1)] = MultiPostThumbnails::get_post_thumbnail_url(get_post_type(), 'twitter-card-gallery-image-' . $i, get_queried_object_id(), 'medium');
}
}
if (!empty($images)) {
$card_data = array_merge($card_data, $images);
}
break;
case 'summary_large_image':
if (MultiPostThumbnails::has_post_thumbnail(get_post_type(), 'twitter-card-large-image', get_queried_object_id())) {
$card_data['image'] = MultiPostThumbnails::get_post_thumbnail_url(get_post_type(), 'twitter-card-large-image', get_queried_object_id(), 'large');
}
break;
case 'product':
if (MultiPostThumbnails::has_post_thumbnail(get_post_type(), 'twitter-card-product-image', get_queried_object_id())) {
$card_data['image'] = MultiPostThumbnails::get_post_thumbnail_url(get_post_type(), 'twitter-card-product-image', get_queried_object_id(), 'large');
}
$card_data['data1'] = get_vpm_value($vpm_group, 'twitter_card_data1', get_queried_object_id());
$card_data['label1'] = get_vpm_value($vpm_group, 'twitter_card_label1', get_queried_object_id());
$card_data['data2'] = get_vpm_value($vpm_group, 'twitter_card_data2', get_queried_object_id());
$card_data['label2'] = get_vpm_value($vpm_group, 'twitter_card_label2', get_queried_object_id());
break;
case 'photo':
case 'summary':
if (has_post_thumbnail()) {
$image = wp_get_attachment_image_src(get_post_thumbnail_id(), 'medium');
if ($image) {
$card_data['image'] = $image[0];
}
}
break;
case 'player':
$card_data['player'] = get_vpm_value($vpm_group, 'twitter_card_player_url', get_queried_object_id());
$card_data['player:width'] = get_vpm_value($vpm_group, 'twitter_card_player_width', get_queried_object_id());
$card_data['player:height'] = get_vpm_value($vpm_group, 'twitter_card_player_height', get_queried_object_id());
$card_data['image'] = get_vpm_value($vpm_group, 'twitter_card_player_image', get_queried_object_id());
break;
}
// Filter Twitter Card data so any values can be overridden externally from the plugin.
$card_data = apply_filters('twitter_card_data', $card_data);
// Gallery cards are not valid unless all four images are set
// Photo cards are not valid unless there is a image set
// If not valid, return empty.
if ($card_type == 'gallery') {
for ($i = 0; $i < 4; $i++) {
if (!isset($card_data['image' . $i]) || empty($card_data['image' . $i])) {
return;
}
}
} else {
if ($card_type == 'photo') {
if (!isset($card_data['image']) || empty($card_data['image'])) {
return;
}
} else {
if ($card_type == 'product') {
foreach (array('image', 'data1', 'label1', 'data2', 'label2') as $required) {
if (!isset($card_data[$required]) || empty($card_data[$required])) {
return;
}
}
} else {
if ($card_type == 'player') {
foreach (array('title', 'description', 'image', 'player', 'player:width', 'player:height') as $required) {
if (!isset($card_data[$required]) || empty($card_data[$required])) {
return;
}
}
if (!empty($card_data['player:stream']) && empty($card_data['player:stream:content_type'])) {
return;
}
}
}
}
}
foreach ($card_data as $key => $value) {
if (empty($value)) {
continue;
}
printf('<meta name="twitter:%s" content="%s" />' . PHP_EOL, esc_attr($key), esc_attr($value));
}
}
示例13: theme_offline_image
/**
*
* @param type $id
* @param type $size
* @return type
*/
public static function theme_offline_image($id = null, $size = 'offline-large')
{
if (!isset($id)) {
$id = self::default_id();
}
if (MultiPostThumbnails::has_post_thumbnail('cwp_custom_options', $id)) {
return MultiPostThumbnails::the_post_thumbnail('cwp_custom_options', 'offline-image', $id, $size);
} else {
return false;
}
}
示例14: get_the_term_names
echo get_the_term_names($post->ID, $post->post_type . '-category', '', ', ', '');
?>
</h2>
<?php
if (has_post_thumbnail()) {
?>
<aside class="entry-image">
<?php
the_post_thumbnail('large');
?>
</aside>
<?php
}
?>
<?php
if (class_exists('MultiPostThumbnails') && MultiPostThumbnails::has_post_thumbnail($post->post_type, $post->post_type . '-secondary', $post->ID)) {
?>
<aside class="entry-image">
<?php
MultiPostThumbnails::the_post_thumbnail($post->post_type, $post->post_type . '-secondary', $post->ID, 'large');
?>
</aside>
<?php
}
?>
<?php
$url = get_post_meta($post->ID, 'entry-url', true);
if (!empty($url)) {
?>
<aside class="entry-url">
<?php
示例15: the_permalink
</div><!-- .entry-content -->
<div class="go-button"><a href="<?php
the_permalink();
?>
" title="<?php
printf(esc_attr__('Permalink to %s', 'magazino'), the_title_attribute('echo=0'));
?>
" rel="bookmark"><?php
_e('▶', 'magazino');
?>
</a></div>
<?php
//Checks for plugin..
if (class_exists('MultiPostThumbnails') && MultiPostThumbnails::has_post_thumbnail(get_post_type(), 'grid-thumbnail', strval(get_the_ID()))) {
?>
<div class="post-box-img"><?php
MultiPostThumbnails::the_post_thumbnail(get_post_type(), 'grid-thumbnail');
?>
</div>
<?php
} else {
//Plugin not installed
?>
<?php
//Checks for attached post image instead
$postimgs =& get_children(array('post_parent' => $post->ID, 'post_type' => 'attachment', 'post_mime_type' => 'image', 'orderby' => 'menu_order', 'order' => 'ASC', 'exclude' => get_post_thumbnail_id()));