コード例 #1
0
function ts_posts_slider_func($atts, $content = null)
{
    extract(shortcode_atts(array("id" => "", "post_type" => "post", "category" => "", "limit" => 10, "orderby" => "date", "order" => "desc", "description" => "excerpt", "excerpt" => 0), $atts));
    switch ($order) {
        case 'asc':
        case 'ASC':
            $order = 'ASC';
            break;
        case 'desc':
        case 'DESC':
        default:
            $order = 'DESC';
            break;
    }
    $post_ids = array();
    if (!empty($id)) {
        $post_ids = explode(',', $id);
    }
    global $query_string, $post;
    $args = array('posts_per_page' => $limit, 'offset' => 0, 'cat' => $category, 'orderby' => $orderby, 'order' => $order, 'post__in' => $post_ids, 'post_type' => $post_type, 'paged' => 1, 'post_status' => 'publish');
    $the_query = new WP_Query($args);
    $content = '';
    if ($the_query->have_posts()) {
        while ($the_query->have_posts()) {
            $the_query->the_post();
            $content .= '<li>';
            $content .= '<article class="post link left post-slider">';
            $embadded_video = '';
            if (get_post_format($post->ID) == 'video') {
                $url = get_post_meta($post->ID, 'video_url', true);
                if (!empty($url)) {
                    $embadded_video = ts_get_embaded_video($url);
                } else {
                    if (empty($url)) {
                        $embadded_video = get_post_meta($post->ID, 'embedded_video', true);
                    }
                }
            }
            if (!empty($embadded_video)) {
                $content .= '<div class="videoWrapper"><img src="' . get_bloginfo("template_directory") . '/img/img16_9.png" alt=""/>';
                $content .= $embadded_video;
                $content .= '</div>';
            } else {
                $content .= ts_get_resized_post_thumbnail_sidebar($post->ID, array('full', 'one-sidebar', 'two-sidebars'));
            }
            $comments = get_comments_number();
            switch ($comments) {
                case 0:
                    $comments_msg = __('No comments', 'circles');
                    break;
                case 1:
                    $comments_msg = __('1 Comment', 'circles');
                    break;
                default:
                    $comments_msg = sprintf(__('%s Comments', 'circles'), $comments);
                    break;
            }
            $content .= '
				<header>
					<a href="' . get_permalink() . '" title="' . esc_attr(get_the_title()) . '">' . get_the_title() . '</a>
				</header>
				<footer>
					<div class="post-helper-absolute">
						<div class="post-day-aside">
							<span>' . get_the_time('d') . '</span>
						</div>
						<div class="post-month-aside">
							<span>' . get_the_time('M') . ', ' . get_the_time('Y') . '</span>
						</div>
					</div>
					<div class="post-author inline">
						By
						<span>
							' . get_the_author_link() . '
						</span>
					</div>
					<div class="post-category">
						<span>
							' . get_the_category_list(', ', '', $post->ID) . '
						</span>
					</div>
					<div class="post-comments inline">
						<span><a href="' . get_permalink() . '#comments">' . $comments_msg . '</a></span>
					</div>
				</footer>';
            if ($description == 'excerpt') {
                $excerpt_limit = 'regular';
                if ((int) $excerpt) {
                    $excerpt_limit = $excerpt;
                }
                $content .= '
					<div class="post-body-text">
						<p>' . ts_get_the_excerpt_theme($excerpt_limit) . ' <a href="' . get_permalink() . '" title="' . esc_attr(get_the_title()) . '" class="read-more">' . __('read more', 'circles') . '</a></p>
					</div>';
            }
            $content .= '</article>';
            $content .= '</li>';
        }
    }
    $rand = rand(1, 5000);
    $content = '
		<div class="flexslider flexslider-posts-slider  images-slider" id="flexslider-posts-slider-' . $rand . '">
			<ul class="slides">
				' . $content . '
			</ul>
		</div>
		<script type="text/javascript">
			jQuery(document).ready(function() {
			  jQuery("#flexslider-posts-slider-' . $rand . '").flexslider({
				animation: "slide",
				controlNav: false,
				prevText: "' . ts_get_prev_slider_text() . '",
				nextText: "' . ts_get_next_slider_text() . '"
			  });
			});
		</script>';
    // Restore original Query & Post Data
    wp_reset_query();
    wp_reset_postdata();
    return $content;
}
コード例 #2
0
function ts_recent_posts_func($atts, $content = null)
{
    extract(shortcode_atts(array("limit" => 10), $atts));
    if (!(int) $limit) {
        $limit = 10;
    }
    $rand = rand(1, 1000);
    global $query_string, $post;
    $args = array('posts_per_page' => $limit, 'offset' => 0, 'cat' => '', 'orderby' => 'date', 'order' => 'DESC', 'include' => '', 'exclude' => '', 'meta_key' => '', 'meta_value' => '', 'post_type' => 'post', 'post_mime_type' => '', 'post_parent' => '', 'paged' => 1, 'post_status' => 'publish');
    $the_query = new WP_Query($args);
    $content = '';
    if ($the_query->have_posts()) {
        $list = '';
        $i = 0;
        while ($the_query->have_posts()) {
            $the_query->the_post();
            $comments = get_comments_number();
            switch ($comments) {
                case 0:
                    $comments_msg = __('No comments', 'circles');
                    break;
                case 1:
                    $comments_msg = __('1 Comment', 'circles');
                    break;
                default:
                    $comments_msg = sprintf(__('%s Comments', 'circles'), $comments);
                    break;
            }
            if ($i > 0) {
                $list .= '<div class="separator"></div>';
            }
            $list .= '
				<article class="post link left">
					<header>
							<a href="' . get_permalink() . '"><h2>' . get_the_title() . '</h2></a>
					</header>
					<footer>
							<div class="post-helper-absolute">
								<div class="post-day-aside">
									<span>' . get_the_time('d') . '</span>
								</div>
								<div class="post-month-aside">
									<span>' . get_the_time('M') . ', ' . get_the_time('Y') . '</span>
								</div>
							</div>
							<div class="post-author inline">
								' . __('By', 'circles') . '
								<span>
									' . get_the_author_link() . '
								</span>
							</div>
							<div class="post-category">
								<span>
									' . get_the_category_list(', ', '', $post->ID) . '
								</span>
							</div>
							<div class="post-comments inline">
								<span><a href="">' . $comments_msg . '</a></span>
							</div>
						</footer>
						<div class="post-body-text">
							
							<p>' . ts_get_the_excerpt_theme('short') . ' <a class="read-more" href="' . get_permalink() . '">' . __('read more', 'circles') . '</a></p>
						</div>
				</article>';
            $i++;
        }
        $content = '
			<section class="grid_12 recent-posts">
				' . $list . '
			</section>';
    }
    // Restor original Query & Post Data
    wp_reset_query();
    wp_reset_postdata();
    return $content;
}
コード例 #3
0
<?php

/** 
 * Meta part for blog classic
 * 
 * @package Rhythm
 */
?>
<!-- Text Intro -->
<div class="blog-item-body">
	<?php 
echo wpautop(ts_get_the_excerpt_theme(30));
?>
</div>