Ejemplo n.º 1
0
    function widget($args, $instance)
    {
        global $post;
        $posts = get_field('products', 'widget_' . $args['widget_id']);
        if ($posts) {
            echo $args['before_widget'];
            if (!empty($instance['title'])) {
                if (!empty($instance['description'])) {
                    echo '<div class="widget-header">';
                    echo $args['before_title'] . $instance['title'] . $args['after_title'];
                    echo '<div class="widget-description">' . $instance['description'] . '</div>';
                    echo '</div>';
                } else {
                    echo $args['before_title'] . $instance['title'] . $args['after_title'];
                }
            }
            ?>

			<ul class="products">
			<?php 
            foreach ($posts as $post) {
                ?>
				<?php 
                setup_postdata($post);
                ?>
				<?php 
                $class = array();
                $class[] = has_post_thumbnail() ? 'has-thumbnail' : '';
                ?>
				<li <?php 
                post_class();
                ?>
>
					
					<?php 
                include_module('product-item', array('title' => get_the_title(), 'designer' => get_field('designer'), 'price' => get_field('price'), 'url' => get_field('external_url'), 'image_url' => get_post_thumbnail_src(array('width' => 210))));
                ?>
				</li>
				<?php 
            }
            ?>
			</ul>
			<?php 
            echo $args['after_widget'];
            wp_reset_postdata();
            wp_reset_query();
        }
    }
Ejemplo n.º 2
0
function feed_thumbnails()
{
    if (function_exists('get_the_image') and $thumb = get_the_image('format=array&echo=0')) {
        $thumb[0] = $thumb['url'];
    } else {
        if (function_exists('has_post_thumbnail') and has_post_thumbnail()) {
            $thumb = wp_get_attachment_image_src(get_post_thumbnail_id(), 'thumbnail');
        } else {
            if (function_exists('get_post_thumbnail_src')) {
                $thumb = get_post_thumbnail_src();
                if (preg_match('|^<img src="([^"]+)"|', $thumb[0], $m)) {
                    $thumb[0] = $m[1];
                }
            } else {
                $thumb = false;
            }
        }
    }
    if (!empty($thumb)) {
        echo "\t" . '<enclosure url="' . $thumb[0] . '" />' . "\n";
    }
}
Ejemplo n.º 3
0
					排序方式:热门度 <span class="glyphicon glyphicon-menu-down"></span>
				</div>
				-->
			</div>
			<!-- BEGIN content -->
			<div class="content container">
				<ul class="grid effect-1" id="grid">
					<?
					$args = array(
						'genre'				=> $genre->slug,
						'post_type'			=> 'product',
						'paged'				=> $paged>1 ? $paged : 1
					);
					$posts = query_posts($args);
					if (have_posts()){ while(have_posts()) : the_post();
						$imgsrc = get_post_thumbnail_src( get_the_ID(), 'full' );
					?>
					<li><a href="<?php 
echo the_permalink();
?>
"><img src="<?php 
echo $imgsrc;
?>
"></a></li>
					<? endwhile;} ?>
				</ul>
			</div>

			<div>
				<? ningone_pagin_nav() ?>
				<!--
Ejemplo n.º 4
0
    function widget($args, $instance)
    {
        global $post;
        $posts = get_field('posts', 'widget_' . $args['widget_id']);
        $size = $instance['size'];
        if ($posts) {
            echo $args['before_widget'];
            if (!empty($instance['title'])) {
                echo $args['before_title'] . $instance['title'] . $args['after_title'];
                ?>
				<?php 
                if (!empty($instance['description'])) {
                    ?>
				<div class="widget-description"><?php 
                    echo $instance['description'];
                    ?>
</div>
				<?php 
                }
                ?>
			<?php 
            }
            ?>

			<ul class="posts size-<?php 
            echo $size;
            ?>
">
			<?php 
            foreach ($posts as $post) {
                ?>
				<?php 
                setup_postdata($post);
                ?>
				<?php 
                $class = array($instance['size']);
                $class[] = has_post_thumbnail() ? 'has-thumbnail' : '';
                switch ($size) {
                    case 'small':
                        $image_size = array('width' => 100, 'height' => 100);
                        $title = get_the_title();
                        break;
                    case 'medium':
                        $image_size = array('width' => 65, 'height' => 65);
                        $title = strlen(get_the_title()) > 25 ? substr(get_the_title(), 0, 25) . ' ...' : get_the_title();
                        break;
                    case 'large':
                    default:
                        $image_size = array('width' => 200, 'height' => 200);
                        $title = get_the_title();
                        break;
                }
                ?>
				<li <?php 
                post_class();
                ?>
>
					
					<?php 
                include_module('post-item', array('title' => $title, 'excerpt' => get_excerpt(50), 'url' => get_permalink(), 'image_url' => get_post_thumbnail_src($image_size), 'class' => implode(' ', $class)));
                ?>
				</li>
				<?php 
            }
            ?>
			</ul>
			<?php 
            echo $args['after_widget'];
            wp_reset_postdata();
            wp_reset_query();
        }
    }
			<?php 
    $i = 1;
    $array = array(1, 8);
    while (have_posts()) {
        the_post();
        ?>
				<?php 
        $image_size = array('width' => 450, 'height' => 290);
        ?>
	            <li >
	            <a href="<?php 
        echo get_permalink();
        ?>
" class="work-item overlay-btn-white">
					<img src="<?php 
        echo get_post_thumbnail_src($image_size);
        ?>
" alt="<?php 
        echo get_the_title();
        ?>
"/>
					<figcaption>
						<div>
							<h2><?php 
        echo get_the_title();
        ?>
</h2>
							<p><?php 
        echo get_excerpt(50);
        ?>
</p>
Ejemplo n.º 6
0
        if ($year != $post_year) {
            ?>
					<div class="year">
						<?php 
            the_date('Y');
            ?>
					</div>
					<?php 
            $year = $post_year;
            ?>
				<?php 
        }
        ?>
	            <li class="item">
	                <?php 
        include_module('post-item', array('title' => get_the_title(), 'url' => get_permalink(), 'image_url' => get_post_thumbnail_src($image_size)));
        ?>
	            </li>								
			<?php 
        $i++;
    }
    // end of the loop.
    ?>
			</ul>

		<?php 
} else {
    ?>
			<div class="not-found">
				<h3 class="title"><?php 
    _e("No posts found", THEME_NAME);
Ejemplo n.º 7
0
					<a class="right carousel-control" href="#product-carousel" role="button" data-slide="next">
						<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
						<span class="sr-only">Next</span>
					</a>
				</div>
			</div>
			<!-- End carousel -->

			<!-- Begin  -->
			<div class="navbar-bottom">
				<div class="container">
					<ul class="nav navbar-nav">
						<?
						$posts = get_posts(array('category_name'=>'product-index-genre-list'));
						for ($i=0; $i < count($posts); $i++) { 
							$src = get_post_thumbnail_src($posts[$i], 'full');
							$link = $posts[$i]->post_content;
						?>
						<li><a href="<?php 
echo $link;
?>
"><img src="<?php 
echo $src;
?>
"></a></li>
						<?
						} // endfor;
						?>
					</ul>
				</div>
			</div>
Ejemplo n.º 8
0
 function get_the_post_thumbnail_src($size = 'thumbnail')
 {
     return get_post_thumbnail_src(get_the_ID(), $size);
 }
/**
 * the_post_thumbnail_src( $post )
 * Echoes out the post thumbnail for the given post.
 *
 * @uses get_post_thumbnail_src()
 * @since v1.0 Initial release.
 **/
function the_post_thumbnail_src($post = null)
{
    echo get_post_thumbnail_src($post);
}
Ejemplo n.º 10
0
 /**
  * Get Post Thumbnail source together with alt and title attributes.
  *
  * @param  int      $post_id    The post id to get the thumbnail from
  * @param  string   $size       Size key of the image to return
  * @return string               Image src together with alt and title attributes
  */
 function get_post_thumbnail($post_id, $size = 'post-thumbnail')
 {
     $html = ' src="' . get_post_thumbnail_src($post_id, $size) . '"';
     $thumb_id = get_post_thumbnail_id($post_id);
     $attachment = get_post($thumb_id);
     // Alt attributes are saved as post meta
     $alt = get_post_meta($thumb_id, '_wp_attachment_image_alt', true);
     // We take the image description for the title
     $title = $attachment->post_content;
     $html .= get_image_attr_html($alt, $title);
     return $html;
 }
Ejemplo n.º 11
0
 function widget($args, $instance)
 {
     global $post;
     $location = $args['id'];
     $args['offset'] = $instance['offset'] ? intval($instance['offset']) - 1 : 0;
     $args['category_id'] = isset($instance['category_id']) && $instance['category_id'] != 0 ? $instance['category_id'] : '';
     $args['size'] = isset($instance['size']) ? $instance['size'] : 'small';
     $args['post_id'] = isset($instance['post_id']) ? $instance['post_id'] : null;
     $options = array('posts_per_page' => 1, 'post_type' => array('post'), 'orderby' => 'date', 'order' => 'DESC', 'post_status' => 'publish');
     if ($args['post_id']) {
         $options['p'] = $args['post_id'];
     } else {
         $options['offset'] = $args['offset'];
         if ($args['category_id']) {
             $options['category__in'] = array($args['category_id']);
         }
     }
     $custom_query = new WP_Query($options);
     if ($custom_query->have_posts()) {
         echo $args['before_widget'];
         $i = 0;
         while ($custom_query->have_posts()) {
             $custom_query->the_post();
             switch ($args['size']) {
                 case 'large':
                     $image_size = array('width' => 320, 'height' => 222);
                     break;
                 case 'medium':
                     $image_size = array('width' => 320, 'height' => 294);
                     break;
                 case 'small':
                 default:
                     $image_size = array('width' => 320, 'height' => 222);
                     break;
             }
             if ($location == 'homepage_carousel') {
                 $image_size = array('width' => 840, 'height' => 480);
             }
             $author_id = get_the_author_meta('ID');
             $category = get_post_category();
             $module = $location == 'homepage_carousel' ? 'post-slide' : 'post-item';
             $sub_category = get_post_sub_category();
             if (!$sub_category || $location == 'homepage_carousel') {
                 $sub_category = $category;
             }
             if ($location != 'homepage_carousel') {
                 include_module('post-top-category', array('name' => $category->name));
             }
             $data = array('title' => get_the_title(), 'excerpt' => get_excerpt(150), 'url' => get_permalink(), 'image_url' => get_post_thumbnail_src($image_size), 'author' => array('name' => get_the_author(), 'image_url' => get_avatar_url(get_the_author_meta('ID'), 40), 'url' => get_author_posts_url($author_id)), 'category' => array('name' => $sub_category->name), 'read_more' => true, 'date' => get_the_date(), 'class' => 'has-sub-category');
             include_module($module, $data);
             $i++;
         }
         echo $args['after_widget'];
         wp_reset_postdata();
         wp_reset_query();
     }
 }