/** * * @param type $query * @param type $tpl * @param type $class */ public static function tpl($query = 'showposts=8', $tpl = 'masonry-grid', $id = "masonry") { //echo '<div id="masonry">'; $_query = new WP_Query($query); if ($_query->have_posts()) { while ($_query->have_posts()) { $_query->the_post(); core_module::tpl($tpl, 'masonry'); } } else { core_mods::modules('sample', 'masonry'); } wp_reset_postdata(); //echo '</div>'; }
public static function tpl($query = 'showposts=3', $data = array('class' => 'flexslider'), $tpl = "flex-slider-index") { ?> <div class="flexslider-container"> <div class="flexslider"> <ul class="slides"> <?php $fx_query = new WP_Query($query); if ($fx_query->have_posts()) { while ($fx_query->have_posts()) { $fx_query->the_post(); core_module::tpl($tpl, 'flex-slider', $data); } } wp_reset_query(); ?> </ul> </div> </div> <?php }
public static function related($tpl = 'related') { global $post; // Reference : http://codex.wordpress.org/Function_Reference/wp_get_post_tags // we are using this function to get an array of tags assigned to current post $tags = wp_get_post_tags($post->ID); if ($tags) { $first_tag = $tags[0]->term_id; // we only need the id of first tag // arguments for query_posts : http://codex.wordpress.org/Function_Reference/query_posts $args = array('tag__in' => array($first_tag), 'post__not_in' => array($post->ID), 'showposts' => 4, 'ignore_sticky_posts' => 1); // WP_Query takes the same arguments as query_posts $related_query = new WP_Query($args); if ($related_query->have_posts()) { core_module::tpl(); wp_reset_query(); // to reset the loop : http://codex.wordpress.org/Function_Reference/wp_reset_query } } else { echo "Sorry there are no Related Post"; } }