예제 #1
0
if (empty($args['posts_per_page'])) {
    return;
}
$args['posts_per_page'] = 14;
$args['current_cat'] = true;
$args = dp_parse_query_args($args);
$query = new WP_Query($args);
if ($query->have_posts()) {
    // Load scripts only when needed
    wp_enqueue_script('jquery-carousel');
    // Get items
    $items = '';
    $i = 0;
    while ($query->have_posts()) {
        $query->the_post();
        $thumb_html = dp_thumb_html('custom-small', '', '', false);
        // Build classname
        $classes = array();
        $classes[] = is_video() ? 'item-video' : 'item-post';
        $class = implode(' ', $classes);
        $items .= '<li class="' . $class . '">' . $thumb_html . '</li>';
    }
    ?>
	
	<div class="cat-featured wall">
		<div class="carousel fcarousel fcarousel-5 wrap cf">
		<div class="carousel-container">
			<div class="carousel-clip">
				<ul class="carousel-list"><?php 
    echo $items;
    ?>
예제 #2
0
    function widget($args, $instance)
    {
        $cache = wp_cache_get('dp_widget_posts', 'widget');
        if (!is_array($cache)) {
            $cache = array();
        }
        if (!isset($args['widget_id'])) {
            $args['widget_id'] = $this->id;
        }
        if (isset($cache[$args['widget_id']])) {
            echo $cache[$args['widget_id']];
            return;
        }
        $style = isset($instance['style']) ? $instance['style'] : 'list';
        extract($args);
        ob_start();
        $title = apply_filters('widget_title', empty($instance['title']) ? __('Recent Posts', 'dp') : $instance['title'], $instance, $this->id_base);
        $query_args = $instance;
        $query_args['no_found_rows'] = true;
        $query_args = dp_parse_query_args($query_args);
        $r = new WP_Query(apply_filters('dp_widget_posts_args', $query_args));
        if ($r->have_posts()) {
            ?>
		
		<?php 
            echo $before_widget;
            ?>
		
		<?php 
            if ($title) {
                echo $before_title . $title . $after_title;
            }
            ?>
		
		<ul class="<?php 
            echo 'post-' . $style;
            ?>
">
			<?php 
            while ($r->have_posts()) {
                $r->the_post();
                $item_format = is_video() ? 'video' : 'post';
                ?>
			<li class="item cf <?php 
                echo 'item-' . $item_format;
                ?>
">
				<?php 
                $image_size = $style == 'list-full' ? 'custom-medium' : 'custom-small';
                dp_thumb_html($image_size);
                ?>
				
				<div class="data">
					<h4 class="entry-title"><a href="<?php 
                the_permalink();
                ?>
" title="<?php 
                echo esc_attr(get_the_title());
                ?>
"><?php 
                the_title();
                ?>
</a></h4>
				
					<p class="meta">
						<span class="author"><?php 
                _e('Added by', 'dp');
                ?>
 <?php 
                the_author_posts_link();
                ?>
</span>
						<span class="time"><?php 
                printf(__('%s ago', 'dp'), human_time(get_the_time('U')));
                ?>
</span>
					</p>
					
					<p class="stats"><?php 
                echo dp_get_post_stats();
                ?>
</p>
				</div>
			</li>
			<?php 
            }
            ?>
		</ul>
		
		<?php 
            echo $after_widget;
            ?>
		
		<?php 
            // Reset the global $the_post as this query will have stomped on it
            wp_reset_postdata();
        }
        $cache[$args['widget_id']] = ob_get_flush();
        wp_cache_set('dp_widget_posts', $cache, 'widget');
    }
예제 #3
0
    function widget($args, $instance)
    {
        if (!is_singular()) {
            return;
        }
        $cache = wp_cache_get('dp_widget_related_posts', 'widget');
        if (!is_array($cache)) {
            $cache = array();
        }
        if (!isset($args['widget_id'])) {
            $args['widget_id'] = $this->id;
        }
        if (isset($cache[$args['widget_id']])) {
            echo $cache[$args['widget_id']];
            return;
        }
        $style = isset($instance['style']) ? $instance['style'] : 'list';
        extract($args);
        ob_start();
        $title = apply_filters('widget_title', empty($instance['title']) ? __('Recent Posts', 'dp') : $instance['title'], $instance, $this->id_base);
        ?>
		
		<?php 
        echo $before_widget;
        ?>
		
		<?php 
        $r = dp_related_posts(array('number' => $instance['posts_per_page'], 'fields' => 'object'));
        if (!$r || !is_object($r) || !$r->have_posts()) {
            return;
        }
        ?>
		
		<?php 
        if ($title) {
            echo $before_title . $title . $after_title;
        }
        ?>
		
		<ul class="<?php 
        echo 'post-' . $style;
        ?>
">
			<?php 
        while ($r->have_posts()) {
            $r->the_post();
            $item_format = is_video() ? 'video' : 'post';
            ?>
			<li class="item cf <?php 
            echo 'item-' . $item_format;
            ?>
">
				<?php 
            $image_size = $style == 'list-full' ? 'custom-medium' : 'custom-small';
            dp_thumb_html($image_size);
            ?>
				
				<div class="data">
					<h4 class="entry-title"><a href="<?php 
            the_permalink();
            ?>
" title="<?php 
            echo esc_attr(get_the_title());
            ?>
"><?php 
            the_title();
            ?>
</a></h4>
				
					<p class="meta">
						<span class="author"><?php 
            _e('Added by', 'dp');
            ?>
 <?php 
            the_author_posts_link();
            ?>
</span>
						<span class="time"><?php 
            printf(__('%s ago', 'dp'), human_time(get_the_time('U')));
            ?>
</span>
					</p>
					
					<p class="stats"><?php 
            echo dp_get_post_stats();
            ?>
</p>
				</div>
			</li>
			<?php 
        }
        wp_reset_query();
        ?>
		</ul>
		
		<?php 
        echo $after_widget;
        ?>
		
		<?php 
        $cache[$args['widget_id']] = ob_get_flush();
        wp_cache_set('dp_widget_related_posts', $cache, 'widget');
    }
예제 #4
0
$item_format = is_video() ? 'video' : 'post';
post_class('item cf item-' . $item_format);
?>
>
		<?php 
// Set image size based on section view, only for section box
global $section_view;
$thumb_size = 'custom-medium';
if (!empty($section_view)) {
    if ($section_view == 'list-large') {
        $thumb_size = 'custom-large';
    } elseif ($section_view == 'grid-mini') {
        $thumb_size = 'custom-small';
    }
}
dp_thumb_html($thumb_size);
?>
			
		<div class="data">
			<h2 class="entry-title"><a href="<?php 
the_permalink();
?>
" rel="bookmark" title="<?php 
printf(__('Permalink to %s', 'dp'), get_the_title());
?>
"><?php 
the_title();
?>
</a></h2>
			
			<p class="entry-meta">