本文整理汇总了PHP中dt_get_thumb_img函数的典型用法代码示例。如果您正苦于以下问题:PHP dt_get_thumb_img函数的具体用法?PHP dt_get_thumb_img怎么用?PHP dt_get_thumb_img使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dt_get_thumb_img函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: widget
function widget($args, $instance)
{
$this->dt_hs_group++;
$instance = wp_parse_args((array) $instance, self::$default_instance);
extract($args);
/* Our variables from the widget settings. */
$title = apply_filters('widget_title', $instance['title']);
$args = array('no_found_rows' => 1, 'post_type' => 'dt_gallery', 'post_status' => 'publish', 'posts_per_page' => -1, 'tax_query' => array(array('taxonomy' => 'dt_gallery_category', 'field' => 'id', 'terms' => $instance['cats'])));
switch ($instance['select']) {
case 'only':
$args['tax_query'][0]['operator'] = 'IN';
break;
case 'except':
$args['tax_query'][0]['operator'] = 'NOT IN';
break;
default:
unset($args['tax_query']);
}
add_filter('posts_clauses', 'dt_core_join_left_filter');
$g_query = new Wp_Query($args);
remove_filter('posts_clauses', 'dt_core_join_left_filter');
$g_arr = array();
if (count($g_query->posts)) {
foreach ($g_query->posts as $album) {
if (post_password_required($album->ID)) {
continue;
}
$g_arr[] = $album->ID;
}
}
dt_storage('where_filter_param', implode(', ', $g_arr));
$args = array('no_found_rows' => 1, 'posts_per_page' => $instance['show'], 'post_type' => 'attachment', 'post_mime_type' => 'image', 'post_status' => 'inherit', 'orderby' => $instance['orderby'], 'order' => $instance['order']);
add_filter('posts_where', 'dt_core_parents_where_filter');
$p_query = new Wp_Query($args);
remove_filter('posts_where', 'dt_core_parents_where_filter');
$hs_slideshow_group = 'dt_widget_latphotos_' . intval($this->dt_hs_group);
echo $before_widget;
// start
echo $before_title . $title . $after_title;
echo '<div class="flickr" data-hs_group="' . $hs_slideshow_group . '">';
if ($p_query->have_posts()) {
foreach ($p_query->posts as $photo) {
if (post_password_required($photo->post_parent)) {
continue;
}
$caption = $photo->post_excerpt;
dt_get_thumb_img(array('img_meta' => wp_get_attachment_image_src($photo->ID, 'full'), 'class' => 'alignleft-f', 'title' => esc_attr($caption), 'alt' => get_post_meta($photo->ID, '_wp_attachment_image_alt', true), 'custom' => ' onclick="return hs.expand(this, { slideshowGroup: \'' . $hs_slideshow_group . '\' } )"', 'thumb_opts' => array('w' => 69, 'h' => 69)));
/*
if ( $caption && 0 )
echo '<div class="highslide-caption">'.$caption.'</div>';
*/
}
}
echo '</div><!-- /.flickr -->';
echo $after_widget;
}
示例2: get_media_item
public static function get_media_item($item_data, $align = 'horizontal')
{
if (!is_object($item_data)) {
return '';
}
$title = '';
$caption = '';
$link = '';
$title_template = '<h4>%s</h4>';
if (!empty($item_data->link)) {
$link_url = $item_data->link;
$link = '<a class="swiper-link" href="' . $link_url . '">' . __('Details', 'the7mk2') . '</a>';
$title_template = '<h4><a href="' . $link_url . '">%s</a></h4>';
}
if (!empty($item_data->title)) {
$title = sprintf($title_template, wp_kses($item_data->title, array()));
}
if (!empty($item_data->description)) {
$caption = wpautop(wp_kses_post($item_data->description));
}
$image = dt_get_thumb_img(array('echo' => false, 'img_meta' => array($item_data->full, $item_data->width, $item_data->height), 'img_id' => $item_data->ID, 'alt' => $item_data->alt, 'wrap' => '<img %IMG_CLASS% %SRC% %SIZE% %ALT% />', 'prop' => false));
$info = $title . $caption . $link;
if ($info) {
$info = sprintf('<span class="link show-content"></span>
<div class="swiper-caption">
%s
<span class="close-link"></span>
</div>', $info);
}
$html = sprintf('<div class="swiper-slide">
%s
%s
</div>', $image, $info);
return $html;
}
示例3: widget
function widget($args, $instance)
{
extract($args);
$instance = wp_parse_args((array) $instance, self::$widget_defaults);
/* Our variables from the widget settings. */
$title = apply_filters('widget_title', $instance['title']);
$args = array('no_found_rows' => 1, 'posts_per_page' => $instance['show'], 'post_type' => 'dt_portfolio', 'post_status' => 'publish', 'orderby' => $instance['orderby'], 'order' => $instance['order'], 'tax_query' => array(array('taxonomy' => 'dt_portfolio_category', 'field' => 'term_id', 'terms' => $instance['cats'])));
switch ($instance['select']) {
case 'only':
$args['tax_query'][0]['operator'] = 'IN';
break;
case 'except':
$args['tax_query'][0]['operator'] = 'NOT IN';
break;
default:
unset($args['tax_query']);
}
$p_query = new WP_Query($args);
// for usage as shortcode
if (!isset($img_size)) {
$img_size = array($instance['max_width'], $instance['max_width']);
}
if (!isset($img_size_origin)) {
$img_size_origin = $img_size;
} else {
$p = $img_size[1] / $img_size[0];
$img_size_origin[1] = round($img_size_origin[0] * $p);
}
echo $before_widget;
// title
if ($title) {
echo $before_title . $title . $after_title;
}
if ($p_query->have_posts()) {
update_post_thumbnail_cache($p_query);
echo '<div class="instagram-photos" data-image-max-width="' . absint($instance['max_width']) . '">';
while ($p_query->have_posts()) {
$p_query->the_post();
$thumb_id = get_post_thumbnail_id(get_the_ID());
if (!has_post_thumbnail(get_the_ID())) {
$args = array('posts_per_page' => 1, 'no_found_rows' => 1, 'post_type' => 'attachment', 'post_mime_type' => 'image', 'post_parent' => get_the_ID(), 'post_status' => 'inherit');
$images = new WP_Query($args);
if ($images->have_posts()) {
$thumb_id = $images->posts[0]->ID;
}
}
$thumb_meta = wp_get_attachment_image_src($thumb_id, 'full');
dt_get_thumb_img(array('img_meta' => $thumb_meta ? $thumb_meta : null, 'img_id' => $thumb_id, 'use_noimage' => true, 'class' => 'post-rollover', 'title' => get_the_title(), 'href' => get_permalink(), 'options' => array('w' => $img_size_origin[0], 'h' => $img_size_origin[1]), 'wrap' => "\n" . '<a %HREF% %TITLE% %CLASS% %CUSTOM%><img %IMG_CLASS% %SRC% ' . image_hwstring($img_size[0], $img_size[1]) . ' %ALT% /></a>' . "\n"));
}
// while have posts
wp_reset_postdata();
echo '</div>';
}
// if have posts
echo $after_widget;
}
示例4: presscore_render_porthole_slider_data
/**
* Porthole slider data.
*
*/
function presscore_render_porthole_slider_data()
{
global $post;
$config = Presscore_Config::get_instance();
$slider_id = $config->get('slideshow_sliders');
$slideshows = presscore_query()->get_posts(array('post_type' => 'dt_slideshow', 'post__in' => $slider_id, 'has_password' => false));
if (!$slideshows || !$slideshows->have_posts()) {
return;
}
$slides = array();
foreach ($slideshows->posts as $slideshow) {
$media_items = get_post_meta($slideshow->ID, '_dt_slider_media_items', true);
if (empty($media_items)) {
continue;
}
$slides = array_merge($slides, $media_items);
}
$slides = array_unique($slides);
$media_query = presscore_query()->get_attachments(array('posts_per_page' => -1, 'orderby' => 'post__in', 'post__in' => $slides));
// prepare data
if ($media_query->have_posts()) {
echo '<ul id="main-slideshow-content" class="royalSlider rsHomePorthole">';
while ($media_query->have_posts()) {
$media_query->the_post();
$video_url = get_post_meta($post->ID, 'dt-video-url', true);
$img_link = get_post_meta($post->ID, 'dt-img-link', true);
$thumb_meta = wp_get_attachment_image_src($post->ID, 'thumbnail');
$hide_title = presscore_imagee_title_is_hidden($post->ID);
$img_custom = 'data-rsTmb="' . $thumb_meta[0] . '"';
if ($video_url) {
$img_custom .= ' data-rsVideo="' . esc_url($video_url) . '"';
}
$img_args = array('img_meta' => wp_get_attachment_image_src($post->ID, 'full'), 'img_id' => $post->ID, 'img_class' => 'rsImg', 'custom' => $img_custom, 'echo' => false, 'wrap' => '<img %IMG_CLASS% %SRC% %CUSTOM% %ALT% %SIZE% />');
$image = dt_get_thumb_img($img_args);
$caption = '';
if (!$config->get('slideshow_hide_captions')) {
if (!$hide_title && ($title = get_the_title())) {
$caption .= '<div class="rsTitle">' . $title . '</div>';
}
if ($content = get_the_content()) {
$caption .= '<div class="rsDesc">' . $content . '</div>';
}
if ($caption) {
$caption = sprintf('<figure class="rsCapt rsABlock">%s</figure>', $caption);
}
if ($img_link) {
$caption = sprintf('<a class="rsCLink" href="%s"><span class="assistive-text">%s</span></a>', esc_url($img_link), __('details', 'the7mk2')) . $caption;
}
}
printf('<li>%s</li>', $image . $caption);
}
wp_reset_postdata();
echo '</ul>';
}
}
示例5: widget
function widget($args, $instance)
{
static $number = 0;
$number++;
extract($args);
$instance = wp_parse_args((array) $instance, self::$widget_defaults);
/* Our variables from the widget settings. */
$title = apply_filters('widget_title', $instance['title']);
// get albums from selected categories
$args = array('no_found_rows' => 1, 'posts_per_page' => -1, 'post_type' => 'dt_gallery', 'post_status' => 'publish', 'tax_query' => array(array('taxonomy' => 'dt_gallery_category', 'field' => 'id', 'terms' => $instance['cats'])));
switch ($instance['select']) {
case 'only':
$args['tax_query'][0]['operator'] = 'IN';
break;
case 'except':
$args['tax_query'][0]['operator'] = 'NOT IN';
break;
default:
unset($args['tax_query']);
}
$p_query = new WP_Query($args);
$attachments_ids_array = array();
// get attachments id
if ($p_query->have_posts()) {
foreach ($p_query->posts as $album) {
// get saved data, hope it's array
$attachments = get_post_meta($album->ID, '_dt_album_media_items', true);
if (!$attachments) {
continue;
}
$attachments_ids_array = array_merge($attachments_ids_array, (array) $attachments);
}
}
$attachments_ids_array = array_unique($attachments_ids_array);
$a_query = false;
if ($attachments_ids_array) {
if ('menu_order' == $instance['orderby']) {
$instance['orderby'] = 'post__in';
if ('DESC' == $instance['order']) {
krsort($attachments_ids_array);
$attachments_ids_array = array_values($attachments_ids_array);
}
}
$a_query = new WP_Query(array('posts_per_page' => $instance['show'], 'no_found_rows' => 1, 'post_type' => 'attachment', 'post_mime_type' => 'image', 'post_status' => 'inherit', 'post__in' => $attachments_ids_array, 'order' => $instance['order'], 'orderby' => $instance['orderby']));
}
echo $before_widget . "\n";
// title
if ($title) {
echo $before_title . $title . $after_title . "\n";
}
if ($a_query && $a_query->have_posts()) {
$share_buttons = presscore_get_share_buttons_for_prettyphoto('photo');
echo '<div class="instagram-photos dt-gallery-container"' . $share_buttons . '>' . "\n";
while ($a_query->have_posts()) {
$a_query->the_post();
$post_id = get_the_ID();
$thumb_meta = wp_get_attachment_image_src($post_id, 'full');
$img = dt_get_thumb_img(array('img_meta' => $thumb_meta, 'img_id' => $post_id, 'class' => 'rollover rollover-small dt-mfp-item mfp-image', 'options' => array('w' => 90, 'h' => 90), 'wrap' => "\n" . '<a %HREF% %CLASS% %CUSTOM% title="%RAW_ALT%" data-dt-img-description="%RAW_TITLE%" data-dt-location="' . esc_attr(get_permalink($post_id)) . '"><img %IMG_CLASS% %SRC% %SIZE% %ALT% /></a>' . "\n"));
}
wp_reset_postdata();
echo '</div>' . "\n";
}
// if have posts
echo $after_widget . "\n";
}
示例6: render_teammate
/**
* This method render's team item.
*
* @param integer $post_id If empty - uses current post id.
*
* @return string Item html.
*/
public static function render_teammate($post_id = null)
{
$post_id = $post_id ? $post_id : get_the_ID();
if (!$post_id) {
return '';
}
$html = '';
$content = get_the_content($post_id);
if ($content) {
$content = '<div class="team-content">' . wpautop($content) . '</div>';
}
// get featured image
$image = '';
if (has_post_thumbnail($post_id)) {
$thumb_id = get_post_thumbnail_id($post_id);
$teammate_thumb_args = array('img_meta' => wp_get_attachment_image_src($thumb_id, 'full'), 'img_id' => $thumb_id, 'options' => false, 'echo' => false, 'wrap' => '<img %IMG_CLASS% %SRC% %SIZE% %IMG_TITLE% %ALT% />');
/**
* Applied filters:
* presscore_set_image_width_based_on_column_width() in template-tags.php
*/
$teammate_thumb_args = apply_filters('teammate_thumbnail_args', $teammate_thumb_args);
$image = dt_get_thumb_img($teammate_thumb_args);
}
// get links
$links = array();
if (function_exists('presscore_get_team_links_array')) {
foreach (presscore_get_team_links_array() as $id => $data) {
$link = get_post_meta($post_id, '_dt_teammate_options_' . $id, true);
if ($link) {
$links[] = presscore_get_social_icon($id, $link, $data['desc']);
}
}
}
if (empty($links)) {
$links = '';
} else {
$links = '<div class="soc-ico">' . implode('', $links) . '</div>';
}
// get position
$position = get_post_meta($post_id, '_dt_teammate_options_position', true);
if ($position) {
$position = '<p>' . $position . '</p>';
} else {
$position = '';
}
// get title
$title = get_the_title($post_id);
if ($title) {
$title = '<div class="team-author-name">' . $title . '</div>';
} else {
$title = '';
}
$author_block = $title . $position;
if ($author_block) {
$author_block = '<div class="team-author">' . $author_block . '</div>';
}
// get it all togeather
$html = sprintf('<div class="team-container">' . "\n\t" . '%1$s<div class="team-desc">%2$s</div>' . "\n\t" . '</div>' . "\n", $image, $author_block . $content . $links);
return $html;
}
示例7: foreach
?>
<?php
// if there are images - put it to the "hidden container"
if ($images->have_posts() && !post_password_required()) {
$hs_group = 'dt_gallery_' . $post->ID;
?>
<div class="hidden-container" data-hs_group="<?php
echo $hs_group;
?>
">
<?php
foreach ($images->posts as $image) {
dt_get_thumb_img(array('class' => 'highslide', 'alt' => get_post_meta($image->ID, '_wp_attachment_image_alt', true), 'img_meta' => wp_get_attachment_image_src($image->ID, 'full'), 'title' => esc_attr(strip_tags($image->post_excerpt)), 'thumb_opts' => array('w' => 90, 'h' => 90)), '<a %HREF% %CLASS% %TITLE% %CUSTOM%><img %ALT% %SRC% %SIZE% /></a>');
?>
<div class="highslide-caption"><?php
echo $image->post_excerpt;
// show like mini button
if (dt_is_page_soc_buttons_enabled('gallery')) {
dt_get_like_window(array('img' => urlencode(current(wp_get_attachment_image_src($image->ID, 'thumbnail'))), 'full' => urlencode(current(wp_get_attachment_image_src($image->ID, 'full'))), 'src' => urlencode(get_permalink($image->ID))));
}
?>
</div>
<?php
}
?>
</div>
<?php
示例8: while
while ($images->have_posts()) {
$images->the_post();
$link = get_post_meta($post->ID, '_dt_slider_link', true);
$hide_desc = get_post_meta($post->ID, '_dt_slider_hdesc', true);
$link_neww = get_post_meta($post->ID, '_dt_slider_newwin', true);
$tmp_arr = array();
if (!empty($post->post_excerpt) && !$hide_desc) {
$tmp_arr['caption'] = get_the_excerpt();
}
if (!empty($post->post_title) && !$hide_desc) {
$tmp_arr['title'] = $post->post_title;
}
$img = wp_get_attachment_image_src($post->ID, 'full');
if ($img) {
if ('fullscreen_slider' != $slider_options['slider']) {
$tmp_arr['src'] = str_replace(array('src="', '"'), '', dt_get_thumb_img(array('img_meta' => $img, 'thumb_opts' => $slide_hw[$slider_options['slider']]), '%SRC%', false));
$tmp_arr['size_str'] = image_hwstring($slide_hw[$slider_options['slider']]['w'], $slide_hw[$slider_options['slider']]['h']);
} else {
$tmp_arr['src'] = $img[0];
$tmp_arr['size_str'] = image_hwstring($img[1], $img[2]);
}
$tmp_arr['alt'] = get_post_meta($post->ID, '_wp_attachment_image_alt', true);
}
if ($link) {
$tmp_arr['link'] = esc_attr($link);
}
$tmp_arr['in_neww'] = intval($link_neww);
$slides_arr[] = $tmp_arr;
}
wp_reset_postdata();
$autoslide = intval($slider_options['auto_period']);
示例9: presscore_get_template_part
case 'aside':
case 'link':
case 'quote':
case 'status':
// post content
presscore_get_template_part('theme', 'blog/blog-post-content-part', $post_format);
break;
case 'image':
default:
$img_class = 'alignnone';
$img_options = false;
// thumbnail
if (has_post_thumbnail() && !$hide_thumbnail) {
$thumb_id = get_post_thumbnail_id();
$thumb_meta = wp_get_attachment_image_src($thumb_id, 'full');
dt_get_thumb_img(array('class' => $img_class . ' rollover rollover-zoom dt-single-mfp-popup dt-mfp-item mfp-image', 'img_meta' => $thumb_meta, 'img_id' => $thumb_id, 'options' => $img_options, 'wrap' => '<a %HREF% %CLASS% %CUSTOM% title="%RAW_ALT%" data-dt-img-description="%RAW_TITLE%"><img %IMG_CLASS% %SRC% %SIZE% %IMG_TITLE% %ALT% /></a>'));
}
// post content
the_content();
}
?>
<?php
wp_link_pages(array('before' => '<div class="page-links">' . __('Pages:', 'the7mk2'), 'after' => '</div>'));
?>
<?php
$post_tags = '';
$config = presscore_get_config();
if ($config->get('post.meta.fields.tags')) {
$post_tags = presscore_get_post_tags_html();
示例10: presscore_get_posts_small_list
/**
* Description here.
*
* Some sort of images list with some description and post title and date ... eah
*
* @return array Array of items or empty array.
*/
function presscore_get_posts_small_list($attachments_data, $options = array())
{
if (empty($attachments_data)) {
return array();
}
global $post;
$default_options = array('links_rel' => '', 'show_images' => true, 'image_dimensions' => array('w' => 60, 'h' => 60));
$options = wp_parse_args($options, $default_options);
$image_args = array('img_class' => '', 'class' => 'alignleft post-rollover', 'custom' => $options['links_rel'], 'options' => array('w' => $options['image_dimensions']['w'], 'h' => $options['image_dimensions']['h'], 'z' => true), 'echo' => false);
$articles = array();
$class = '';
$post_was_changed = false;
$post_backup = $post;
foreach ($attachments_data as $data) {
$new_post = null;
if (isset($data['parent_id'])) {
$post_was_changed = true;
$new_post = get_post($data['parent_id']);
if ($new_post) {
$post = $new_post;
setup_postdata($post);
}
}
$permalink = esc_url($data['permalink']);
$attachment_args = array('href' => $permalink, 'img_meta' => array($data['full'], $data['width'], $data['height']), 'img_id' => empty($data['ID']) ? 0 : $data['ID'], 'echo' => false, 'wrap' => '<a %CLASS% %HREF% %CUSTOM%><img %IMG_CLASS% %SRC% %SIZE% %ALT% /></a>');
// show something if there is no title
if (empty($data['title'])) {
$data['title'] = _x('No title', 'blog small list', 'the7mk2');
}
if (!empty($data['parent_id'])) {
$class = 'post-' . presscore_get_post_format_class(get_post_format($data['parent_id']));
if (empty($data['ID'])) {
$attachment_args['wrap'] = '<a %HREF% %CLASS% %TITLE% style="width:' . $options['image_dimensions']['w'] . 'px; height: ' . $options['image_dimensions']['h'] . 'px;"></a>';
$attachment_args['class'] = $image_args['class'] . ' no-avatar';
$attachment_args['img_meta'] = array('', 0, 0);
$attachment_args['options'] = false;
}
}
$article = sprintf('<article class="%s"><div class="wf-td">%s</div><div class="post-content">%s%s</div></article>', $class, $options['show_images'] ? dt_get_thumb_img(array_merge($image_args, $attachment_args)) : '', '<a href="' . $permalink . '">' . esc_html($data['title']) . '</a><br />', '<time class="text-secondary" datetime="' . get_the_date('c') . '">' . get_the_date(get_option('date_format')) . '</time>');
$articles[] = $article;
}
if ($post_was_changed) {
$post = $post_backup;
setup_postdata($post);
}
return $articles;
}
示例11: array
$align = 'alignleft';
$custom = 'style="width: 270px;"';
$thumb_options = array('w' => 270, 'z' => 1);
}
$thumb_args = array('img_meta' => $thumb_meta, 'img_id' => $thumb_id, 'class' => $align . ' rollover dt-single-mfp-popup dt-mfp-item mfp-image', 'options' => $thumb_options, 'custom' => $custom, 'echo' => false, 'wrap' => '<a %HREF% %CLASS% %CUSTOM% %IMG_TITLE% data-dt-img-description="%RAW_TITLE%"><img %IMG_CLASS% %SRC% %IMG_TITLE% %ALT% %SIZE% /></a>');
if ('list' != $layout) {
if ('wide' == $preview_mode && !$config->get('all_the_same_width')) {
$target_image_width = $config->get('target_width') * 3;
$thumb_args['options'] = array('w' => round($target_image_width), 'z' => 0, 'hd_convert' => false);
} else {
$target_image_width = $config->get('target_width') * 1.5;
$thumb_args['options'] = array('w' => round($target_image_width), 'z' => 0);
}
}
$thumb_args = apply_filters('dt_post_thumbnail_args', $thumb_args);
$media = dt_get_thumb_img($thumb_args);
if ('list' != $layout) {
$media = '<p>' . $media . '</p>';
}
echo $media;
}
?>
</div>
<div class="blog-content wf-td">
<h2 class="entry-title">
<a href="<?php
the_permalink();
?>
" title="<?php
echo the_title_attribute('echo=0');
?>
示例12: get_slide_thumbnail
protected function get_slide_thumbnail(&$slide)
{
$args = array('img_meta' => $slide->image_src, 'img_id' => $slide->id, 'alt' => $slide->image_alt, 'options' => array('w' => $this->settings['thumbnails_width'] ? $this->settings['thumbnails_width'] : null, 'h' => $this->settings['thumbnails_height'], 'z' => 1), 'wrap' => '<img %IMG_CLASS% %SRC% %SIZE% %ALT% />', 'echo' => false);
return dt_get_thumb_img($args);
}
示例13: widget
function widget($args, $instance)
{
extract($args);
$instance = wp_parse_args((array) $instance, $this->dt_defaults);
/* Our variables from the widget settings. */
$title = apply_filters('widget_title', $instance['title']);
$autoslide = $instance['autoslide'];
$autoslide_on = $autoslide ? 1 : 0;
global $wpdb;
$args = array('no_found_rows' => 1, 'posts_per_page' => $instance['show'], 'post_type' => 'dt_team', 'post_status' => 'publish', 'orderby' => $instance['orderby'], 'order' => $instance['order'], 'tax_query' => array(array('taxonomy' => 'dt_team_category', 'field' => 'id', 'terms' => $instance['cats'])));
switch ($instance['select']) {
case 'only':
$args['tax_query'][0]['operator'] = 'IN';
break;
case 'except':
$args['tax_query'][0]['operator'] = 'NOT IN';
break;
default:
unset($args['tax_query']);
}
add_filter('posts_clauses', 'dt_core_join_left_filter');
$p_query = new WP_Query($args);
remove_filter('posts_clauses', 'dt_core_join_left_filter');
// caching!
if ($p_query->have_posts()) {
$images = array();
foreach ($p_query->posts as $p) {
if (has_post_thumbnail($p->ID)) {
$images[] = get_post_thumbnail_id($p->ID);
}
}
if ($images) {
$i_query = new WP_Query(array('no_found_rows' => 1, 'posts_per_page' => -1, 'post_type' => 'attachment', 'post_status' => 'inherit', 'post__in' => $images));
}
}
echo $before_widget;
// start
echo $before_title . $title . $after_title;
?>
<div class="reviews-t coda-team">
<?php
if ($p_query->have_posts()) {
// remove jetpack share buttons filter
remove_filter('the_content', 'sharing_display', 19);
$data = array();
foreach ($p_query->posts as $teammate) {
$teammate_data = get_post_meta($teammate->ID, '_dt_team_info', true);
$position = isset($teammate_data['position']) ? $teammate_data['position'] : '';
$age = isset($teammate_data['age']) ? '<br />' . $teammate_data['age'] : '';
$thumb_id = get_post_thumbnail_id($teammate->ID);
if (has_post_thumbnail($teammate->ID)) {
$thumb_meta = wp_get_attachment_image_src($thumb_id, 'full');
} else {
$thumb_meta = null;
}
// get alt
$img_alt = get_post_meta($thumb_id, '_wp_attachment_image_alt', true);
if (!$img_alt) {
$img_alt = get_the_title($teammate->ID);
}
ob_start();
?>
<div class="team-wrap">
<?php
dt_get_thumb_img(array('img_meta' => $thumb_meta, 'alt' => $img_alt, 'use_noimage' => true, 'img_class' => 'alignleft', 'thumb_opts' => array('w' => 80, 'h' => 100)), '<img %SRC% %IMG_CLASS% %SIZE% %ALT% />');
?>
<span class="head"><?php
echo $teammate->post_title;
?>
</span>
<?php
if (isset($position) || isset($age)) {
?>
<p class="mid-gray"><span><?php
echo $position . $age;
?>
</span></p>
<?php
}
?>
<div class="team-description"><?php
echo apply_filters('the_content', strip_shortcodes($teammate->post_content));
?>
</div>
</div>
<?php
$str = ob_get_clean();
$data[] = array($str);
}
$auto_data = sprintf('data-autoslide="%s" data-autoslide_on="%s"', $autoslide, $autoslide_on);
dt_get_coda_slider(array('wrap' => '<div class="list-carousel coda bx"><ul class="slider1" ' . $auto_data . '>%SLIDER%</ul></div>', 'item_wrap' => '<li>%1$s</li>', 'data' => $data));
}
?>
</div>
//.........这里部分代码省略.........
示例14: widget
function widget($args, $instance)
{
extract($args);
$instance = wp_parse_args((array) $instance, $this->dt_defaults);
/* Our variables from the widget settings. */
$title = apply_filters('widget_title', $instance['title']);
$autoslide = $instance['autoslide'];
$autoslide_on = $autoslide ? 1 : 0;
global $wpdb, $post;
$args = array('no_found_rows' => 1, 'posts_per_page' => 1, 'post_type' => 'dt_slider', 'post_status' => 'publish', 'post__in' => array($instance['cats']));
$p_query = new WP_Query($args);
echo $before_widget;
// start
echo $before_title . $title . $after_title;
?>
<div class="navig-small">
<a class="SliderNamePrev" href="javascript:void(0);"></a>
<a class="SliderNameNext" href="javascript:void(0);"></a>
</div>
<div class="slider_container_1">
<?php
if ($p_query->have_posts()) {
$slides_arr = array();
foreach ($p_query->posts as $album) {
$args = array('no_found_rows' => 1, 'posts_per_page' => $instance['show'], 'post_type' => 'attachment', 'post_mime_type' => 'image', 'post_parent' => $album->ID, 'post_status' => 'inherit', 'orderby' => 'menu_order', 'order' => 'ASC');
$images = new WP_Query($args);
if ($images->have_posts()) {
while ($images->have_posts()) {
$images->the_post();
$link = get_post_meta($post->ID, '_dt_slider_link', true);
$hide_desc = !!get_post_meta($post->ID, '_dt_slider_hdesc', true);
$link_neww = get_post_meta($post->ID, '_dt_slider_newwin', true);
$tmp_arr = array();
if (!empty($post->post_excerpt) && !$hide_desc) {
$tmp_arr['caption'] = wp_trim_words(get_the_excerpt(), 15, '');
}
if (!empty($link)) {
$tmp_arr['link'] = $link;
}
if (!empty($link_neww)) {
$tmp_arr['link_neww'] = true;
}
if (!empty($post->post_title) && !$hide_desc) {
$tmp_arr['title'] = $post->post_title;
}
$img = wp_get_attachment_image_src($post->ID, 'full');
if ($img) {
$tmp_arr['src'] = str_replace(array('src="', '"'), '', dt_get_thumb_img(array('img_meta' => $img, 'thumb_opts' => array('w' => 210, 'h' => 210)), '%SRC%', false));
$tmp_arr['size_str'] = image_hwstring(210, 210);
$tmp_arr['alt'] = esc_attr(get_post_meta($post->ID, '_wp_attachment_image_alt', true));
}
$slides_arr[] = $tmp_arr;
}
} else {
?>
<div style="color: red; margin: 0 auto; padding: 20px; text-shadow: none; "><?php
_e('There are no images in the slider.', LANGUAGE_ZONE);
?>
</div>
<?php
}
}
$images = $caption = '';
$i = 1;
foreach ($slides_arr as $slide) {
$slide_link = '';
if (!empty($slide['link'])) {
$slide_link = '<div class="link"><a href="' . esc_url($slide['link']) . '"' . (!empty($slide['link_neww']) ? 'target="_blank"' : '') . '></a></div>';
}
$caption .= '<div class="nivo-html-caption caption-' . $i . '">';
if (!empty($slide['caption'])) {
$caption .= '<p>' . $slide['caption'] . '</p>';
}
$caption .= $slide_link . '</div>';
$images .= '<img src="' . $slide['src'] . '" alt="' . $slide['alt'] . '" title=".caption-' . $i . '" ' . $slide['size_str'] . ' />';
$i++;
}
?>
<div class="widget_slider" data-autoslide="<?php
echo $autoslide;
?>
" data-autoslide_on="<?php
echo $autoslide_on;
?>
"><?php
echo $images;
?>
</div><?php
echo $caption;
?>
</div>
<?php
}
wp_reset_postdata();
echo $after_widget;
//.........这里部分代码省略.........
示例15: array
$post_classes = array('dt-testimon');
if (1 == $posts_count) {
$post_classes[] = 'first';
}
?>
<div class="<?php
echo implode(' ', $post_classes);
?>
">
<div class="panel-wrapper"><?php
the_content();
?>
</div>
<div class="panel-author"><?php
if (has_post_thumbnail($post_id)) {
dt_get_thumb_img(array('img_meta' => wp_get_attachment_image_src(get_post_thumbnail_id($post_id), 'full'), 'thumb_opts' => array('w' => 30, 'h' => 30)), '<img class="alignleft" %SRC% %SIZE% %ALT%/>');
}
if ($author = get_the_title()) {
?>
<p class="author-name"><?php
echo $author;
?>
</p><?php
}
if (!empty($opts['position'])) {
?>
<span class="author-position"><?php
echo $opts['position'];
?>
</span><?php
}