Example #1
0
			<?php 
if (shamrock_get_option('single_show_cat')) {
    ?>
				<?php 
    the_category();
    ?>
			<?php 
}
?>

			<?php 
the_title(sprintf('<h1 class="entry-title">', esc_url(get_permalink())), '</h1>');
?>

			<?php 
if ($meta = shamrock_get_meta_data()) {
    ?>
				<div class="entry-meta">
					<?php 
    echo $meta;
    ?>
				</div>
			<?php 
}
?>

		</header>

	</div>

	<?php 
Example #2
0
    function widget($args, $instance)
    {
        extract($args);
        $instance = wp_parse_args((array) $instance, $this->defaults);
        echo $before_widget;
        $title = apply_filters('widget_title', $instance['title']);
        if (!empty($title)) {
            echo $before_title . $title . $after_title;
        }
        $q_args = array('post_type' => 'post', 'posts_per_page' => $instance['numposts'], 'ignore_sticky_posts' => 1, 'orderby' => $instance['orderby']);
        if (!empty($instance['manual']) && !empty($instance['manual'][0])) {
            $q_args['posts_per_page'] = absint(count($instance['manual']));
            $q_args['orderby'] = 'post__in';
            $q_args['post__in'] = $instance['manual'];
            $q_args['post_type'] = array_keys(get_post_types(array('public' => true)));
            //support all existing public post types
        } else {
            if (!empty($instance['auto_detect']) && is_single()) {
                $cats = get_the_category();
                if (!empty($cats)) {
                    foreach ($cats as $k => $cat) {
                        $q_args['category__in'][] = $cat->term_id;
                    }
                }
            } else {
                if (!empty($instance['category'])) {
                    $q_args['category__in'] = (array) $instance['category'];
                }
            }
            if ($instance['orderby'] == 'views' && function_exists('ev_get_meta_key')) {
                $q_args['orderby'] = 'meta_value_num';
                $q_args['meta_key'] = ev_get_meta_key();
            }
            if (!empty($instance['date_limit'])) {
                $q_args['date_query'] = array('after' => date('Y-m-d', strtotime($instance['date_limit'])));
            }
        }
        $shamrock_posts = new WP_Query($q_args);
        if ($shamrock_posts->have_posts()) {
            ?>

		<ul>

			<?php 
            while ($shamrock_posts->have_posts()) {
                $shamrock_posts->the_post();
                ?>

		 		<li>
		 			<a href="<?php 
                echo esc_url(get_permalink());
                ?>
"  title="<?php 
                echo esc_attr(get_the_title());
                ?>
">
		 				<?php 
                if (has_post_thumbnail()) {
                    ?>
		 					<?php 
                    the_post_thumbnail('thumbnail');
                    ?>
		 				<?php 
                } else {
                    ?>
		 					<?php 
                    echo shamrock_placeholder_img();
                    ?>
		 				<?php 
                }
                ?>

		 			</a>
		 			<a href="<?php 
                echo esc_url(get_permalink());
                ?>
" title="<?php 
                echo esc_attr(get_the_title());
                ?>
"><?php 
                the_title();
                ?>
</a>
		 			<?php 
                if (!empty($instance['meta']) && ($meta = shamrock_get_meta_data($instance['meta']))) {
                    ?>
		 				<div class="entry-meta"><?php 
                    echo $meta;
                    ?>
</div>
		 			<?php 
                }
                ?>
		 		</li>
			<?php 
            }
            ?>

		  </ul>
		<?php 
        }
        ?>

		<?php 
        wp_reset_postdata();
        ?>

		<?php 
        echo $after_widget;
    }