/** * Outputs the HTML for this widget. * * @param array An array of standard parameters for widgets in this theme * @param array An array of settings for this widget instance * @return void Echoes it's output */ function widget($args, $instance) { extract($args, EXTR_SKIP); echo $before_widget; $title = apply_filters('widget_title', $instance['title']); if ($title != '') { echo $before_title; echo $title; echo $after_title; } // Remove the filter from the Posts Order By Plugin if (function_exists('CPTOrderPosts')) { remove_filter('posts_orderby', 'CPTOrderPosts', 99, 2); } // Get the articles $args = array('post_type' => 'post', 'posts_per_page' => $instance['number'], 'meta_key' => 'ipt_kb_like_article', 'meta_value' => '0', 'meta_compare' => '>', 'orderby' => 'meta_value_num', 'order' => 'DESC'); $args = apply_filters('ipt_kb_popular_widget_query_args', $args); $popular_posts = new WP_Query($args); echo '<div class="list-group">'; if ($popular_posts->have_posts()) { while ($popular_posts->have_posts()) { $popular_posts->the_post(); get_template_part('category-templates/content', 'popular'); } } else { get_template_part('category-templates/no-result'); } echo '</div>'; wp_reset_query(); // Add the filter from the Posts Order By Plugin if (function_exists('CPTOrderPosts')) { add_filter('posts_orderby', 'CPTOrderPosts', 99, 2); } echo $after_widget; }
function generate_ryuzine_stylesheets() { // verify this came from the our screen and with proper authorization. if (!wp_verify_nonce($_POST['ryu_regenstyles_noncename'], 'ryuzine-regenstyles_install')) { return; } // Check permissions if (!current_user_can('administrator')) { echo "<div class='error'><p>Sorry, you do not have the correct priveledges to install the files.</p></div>"; return; } $my_query = null; $my_query = new WP_Query(array('post_type' => 'ryuzine')); if ($my_query->have_posts()) { while ($my_query->have_posts()) { $my_query->the_post(); $stylesheet = ""; $issuestyles = get_post_meta(get_the_ID(), '_ryustyles', false); if (!empty($issuestyles)) { foreach ($issuestyles as $appendstyle) { // If there are multiple ryustyles append them // $stylesheet = $stylesheet . $appendstyle; } } if ($stylesheet != "") { ryu_create_css($stylesheet, get_the_ID()); } } } // reset css check // // update_option('ryu_css_admin',0); wp_reset_query(); return; }
function widget($args, $instance) { extract($args, EXTR_SKIP); $instance = wp_parse_args($instance, array('title' => __('Latest Questions', 'dwqa'), 'number' => 5)); echo $before_widget; echo $before_title; echo $instance['title']; echo $after_title; $args = array('posts_per_page' => $instance['number'], 'order' => 'DESC', 'orderby' => 'post_date', 'post_type' => 'dwqa-question', 'suppress_filters' => false); $questions = new WP_Query($args); if ($questions->have_posts()) { echo '<div class="dwqa-popular-questions">'; echo '<ul>'; while ($questions->have_posts()) { $questions->the_post(); echo ' <li><a href="' . get_permalink() . '" class="question-title">' . get_the_title() . '</a> ' . __('asked by', 'dwqa') . ' ' . (dwqa_is_anonymous(get_the_ID()) ? __('Anonymous', 'dwqa') : get_the_author_link()) . ', ' . human_time_diff(get_the_time('U'), current_time('timestamp')) . ' ago'; '</li>'; } echo '</ul>'; echo '</div>'; } wp_reset_query(); wp_reset_postdata(); echo $after_widget; }
function service_shortcode($atts) { extract(shortcode_atts(array('category' => '', 'type' => '', 'sitem' => ''), $atts, 'wishlist')); $service_return = ''; $service_return .= '<div class="container"><div class="row">'; $q = new WP_Query(array('post_type' => array('service'), 'post_status' => array('publish'), 'orderby' => 'date', 'order' => 'DESC', 'posts_per_page' => $sitem, 'service-category' => $category)); $service_return = '<div class="item active">'; while ($q->have_posts()) { $q->the_post(); //$idz = get_the_ID(); $icon = get_post_meta(get_the_ID(), 'serviceIcon', true); if ($icon != '' && $icon != 1) { $ico = 'fa ' . $icon; } else { $ico = 'fa fa-bomb'; } $service_return .= ' <div class="col-md-3 col-sm-6 wow zoomIn text-center" data-wow-duration="700ms" data-wow-delay="300ms"> <div class="service-icon"> <i class="' . $ico . '"></i> </div> <div class="service-text"> <h4>' . get_the_title() . '</h4> <p>' . substr(get_the_content(), 0, 150) . '</p> </div> </div> '; } $service_return .= '</div>'; wp_reset_query(); $service_return .= '</div>'; return $service_return; }
function widget($args, $instance) { extract($args); $title = apply_filters('widget_title', $instance['title']); $number = $instance['number']; echo $before_widget; if ($title) { echo $before_title . $title . $after_title; } ?> <div class="recent-works-items clearfix"> <?php $args = array('post_type' => 'evolve_portfolio', 'posts_per_page' => $number, 'has_password' => false); $portfolio = new WP_Query($args); if ($portfolio->have_posts()) { ?> <?php while ($portfolio->have_posts()) { $portfolio->the_post(); ?> <?php if (has_post_thumbnail()) { ?> <?php $link_target = ""; $url_check = get_post_meta(get_the_ID(), 'pyre_link_icon_url', true); if (!empty($url_check)) { $new_permalink = get_post_meta(get_the_ID(), 'pyre_link_icon_url', true); if (get_post_meta(get_the_ID(), 'pyre_link_icon_target', true) == "yes") { $link_target = ' target="_blank"'; } } else { $new_permalink = get_permalink(); } ?> <a href="<?php echo $new_permalink; ?> "<?php echo $link_target; ?> title="<?php the_title(); ?> "> <?php the_post_thumbnail('recent-works-thumbnail'); ?> </a> <?php } } } wp_reset_query(); ?> </div> <?php echo $after_widget; }
function featured_index() { $output = ''; $args = array('tag' => 'featured', 'posts_per_page' => 3); query_posts($args); if (have_posts()) { while (have_posts()) { the_post(); $the_img = $this->get_img_src(get_the_ID()); if ($the_img == 'zero') { } $output .= '<div class=" mdl-cell mdl-cell--4-col mdl-card mdl-shadow--2dp">'; $output .= ' <div class="mdl-card__title mdl-card--expand" style="background-image: url( \' ' . $the_img . ' \' )"> </div> <div class="mdl-card__supporting-text"> ' . get_the_title() . ' </div> <div class="mdl-card__actions mdl-card--border"> <a class="mdl-button mdl-button--colored mdl-js-button mdl-js-ripple-effect"> View Updates </a> </div>'; $output .= '</div>'; } } else { $output = 'gagal'; } wp_reset_query(); return $output; }
function sys_recent_posts($atts, $content = null) { extract(shortcode_atts(array('limit' => '2', 'description' => '40', 'cat_id' => '23', 'thumb' => 'true', 'postdate' => ''), $atts)); $out = '<div class="widget_postslist sc">'; $out .= '<ul>'; global $wpdb; $myposts = get_posts("numberposts={$limit}&offset=0&cat={$cat_id}"); foreach ($myposts as $post) { $post_date = $post->post_date; $post_date = mysql2date('F j, Y', $post_date, false); $out .= "<li>"; if ($thumb == "true") { $thumbid = get_post_thumbnail_id($post->ID); $imgsrc = wp_get_attachment_image_src($thumbid, array(9999, 9999)); $out .= '<div class="thumb"><a href="' . get_permalink($post->ID) . '" title="' . $post->post_title . '">'; if ($thumbid) { $out .= atp_resize('', $imgsrc['0'], '50', '50', 'imgborder', ''); } else { //$out .= '<img class="imgborder" src="'.THEME_URI.'/images/no-image.jpg'.'" alt="' .$post->post_title. '" />'; } $out .= '</a></div>'; } $out .= '<div class="pdesc"><a href="' . get_permalink($post->ID) . '" rel="bookmark">' . $post->post_title . '</a>'; if ($postdate == "true") { $out .= '<div class="w-postmeta"><span>' . $post_date . '</span></div>'; } else { $out .= '<p>' . wp_html_excerpt($post->post_content, $description, '...') . '</p>'; } $out .= '</div></li>'; } $out .= '</ul></div>'; return $out; wp_reset_query(); }
function writeShoppingCart() { global $wpdb; $settings = $wpdb->get_row("SELECT * FROM " . $wpdb->prefix . "photocrati_ecommerce_settings WHERE id = 1", ARRAY_A); foreach ($settings as $key => $value) { ${$key} = $value; } $cart = $_SESSION['cart']; if (!$cart) { return '<p><em>' . $ecomm_empty . '</em> </p>'; } else { // Parse the cart session variable $items = explode(',', $cart); $s = count($items) > 1 ? 's' : ''; if (get_option('permalink_structure') != '') { return '<button id="addto2" class="positive" style="margin:0 5px;" onClick=\'window.location.href = "' . get_bloginfo('url') . '/' . str_replace(" ", "-", strtolower($ecomm_title)) . '/"\'><img src="' . photocrati_gallery_file_uri('image/cart.png') . '"> ' . $ecomm_title . ': ' . count($items) . ' item' . $s . '</button>'; } else { $pgid = query_posts(array('pagename' => $ecomm_title)); foreach ($pgid as $pgid) { $pageid = $pgid->ID; } wp_reset_query(); return '<button id="addto2" class="positive" style="margin:0 5px;" onClick=\'window.location.href = "' . get_bloginfo('url') . '/?page_id=' . $pageid . '"\'><img src="' . photocrati_gallery_file_uri('image/cart.png') . '"> ' . $ecomm_title . ': ' . count($items) . ' item' . $s . '</button>'; } } }
function ktz_mustread_content() { global $post; if (ot_get_option('ktz_popup_activated') == 'yes') { $paged = get_query_var('paged') ? get_query_var('paged') : 1; $args = array('post_type' => 'post', 'orderby' => 'rand', 'order' => 'desc', 'showposts' => 3, 'post_status' => 'publish', 'ignore_sticky_posts' => 1); $ktz_topfeatquery = new WP_Query($args); if ($ktz_topfeatquery->have_posts()) { echo '<div id="ktz_slidebox">'; echo '<strong class="mustread_title">' . __('Must read', ktz_theme_textdomain) . '</strong><a href="#" class="close">×</a>'; echo '<ul class="mustread_list">'; while ($ktz_topfeatquery->have_posts()) { $ktz_topfeatquery->the_post(); echo '<li class="mustread_li">'; echo '<div class="title">'; echo ktz_posted_title_a(); echo '</div>'; echo '</li>'; } echo '</ul>'; echo '</div>'; } wp_reset_query(); } }
function film_shortcode_query($atts, $content) { extract(shortcode_atts(array('posts_per_page' => '1', 'post_type' => 'landing', 'caller_get_posts' => 1), $atts)); global $post; $posts = new WP_Query($atts); $output = ''; if ($posts->have_posts()) { while ($posts->have_posts()) { $posts->the_post(); $out = '<div class="film_box"> <h4>Film Name: <a href="' . get_permalink() . '" title="' . get_the_title() . '">' . get_the_title() . '</a></h4> <p class="Film_desc">' . get_the_content() . '</p>'; // add here more... $out .= '</div>'; /* these arguments will be available from inside $content get_permalink() get_the_content() get_the_category_list(', ') get_the_title() and custom fields get_post_meta($post->ID, 'field_name', true); */ } } else { return; } // no posts found wp_reset_query(); return html_entity_decode($out); }
function widget($args, $instance) { extract($args, EXTR_SKIP); $instance = wp_parse_args($instance, array('title' => __('Closed Questions', 'dwqa'), 'number' => 5)); echo $before_widget; echo $before_title; echo $instance['title']; echo $after_title; $args = array('post_type' => 'dwqa-question', 'meta_query' => array('relation' => 'OR', array('key' => '_dwqa_status', 'compare' => '=', 'value' => 'resolved'), array('key' => '_dwqa_status', 'compare' => '=', 'value' => 'closed'))); $questions = new WP_Query($args); if ($questions->have_posts()) { echo '<div class="dwqa-popular-questions">'; echo '<ul>'; while ($questions->have_posts()) { $questions->the_post(); echo ' <li><a href="' . get_permalink() . '" class="question-title">' . get_the_title() . '</a> ' . __('asked by', 'dwqa') . ' ' . get_the_author_link(); '</li>'; } echo '</ul>'; echo '</div>'; } wp_reset_query(); wp_reset_postdata(); echo $after_widget; }
function widget($args, $instance) { if (!is_home()) { return false; } /* Query the first post: If it has a featured image, display it, and store its ID in an array. */ query_posts('posts_per_page=1'); while (have_posts()) { the_post(); $do_not_duplicate[] = $post->ID; get_template_part('feature', 'index'); } /* Excerpt post loop. If a #feature post exists, do not duplicate. */ if ((int) $instance['excerpts_count'] > 0) { query_posts(array('post__not_in' => $do_not_duplicate, 'offset' => 1, 'posts_per_page' => (int) $instance['excerpts_count'])); echo '<div class="clearfix">'; for ($post_count = 1; have_posts(); $post_count++) { the_post(); $do_not_duplicate[] = $post->ID; /* See: lib/helpers.php -> sourdough_excerpt() */ sourdough_excerpt($post_count); } echo '</div>'; } wp_reset_query(); }
function adm_sitemap_posts($atts) { extract(shortcode_atts(array('comments_number' => true, 'number' => '0', 'cat' => '', 'posts' => '', 'author' => '', 'type' => 'post', 'comments' => 'true'), $atts)); if ($number == 0) { $number = 1000; } if ($comments_number === 'false') { $comments_number = false; } $query = array('showposts' => (int) $number, 'post_type' => $type); if ($cat) { $query['cat'] = $cat; } if ($posts) { $query['post__in'] = explode(',', $posts); } if ($author) { $query['author'] = $author; } $archive_query = new WP_Query($query); $output = ''; while ($archive_query->have_posts()) { $archive_query->the_post(); $output .= '<li><a href="' . get_permalink() . '" rel="bookmark" title="' . sprintf(__("Permanent Link to %s", 'striking_front'), get_the_title()) . '">' . get_the_title() . '</a>'; if ($comments == 'true') { $output .= $comments_number ? ' (' . get_comments_number() . ')' : ''; } $output .= '</li>'; } wp_reset_query(); return '<div class="sc-sitemap sitemap-posts"><ul>' . $output . '</ul></div>'; }
/** * Speaker Loop * */ function sc_speaker_loop() { $args = array('post_type' => 'sc-speakers', 'posts_per_page' => '-1', 'orderby' => 'menu_order', 'order' => 'ASC'); $loop = new WP_Query($args); if ($loop->have_posts()) { while ($loop->have_posts()) { $loop->the_post(); global $post; echo '<div class="speaker"><div class="one-half first">'; $image = wp_get_attachment_image_src(get_post_thumbnail_id(), 'sc_thumbnail'); if ($image) { echo '<p><img src="' . $image[0] . '" class="border" alt="' . get_the_title() . '" /></p>'; } $url = esc_url(get_post_meta($post->ID, 'sc_speaker_url', true)); if (!empty($url)) { echo '<h4><a href="' . $url . '" target="_blank">' . $url . '</a></h4>'; } $twitter = esc_attr(get_post_meta($post->ID, 'sc_speaker_twitter', true)); if (!empty($twitter)) { echo '<p><a href="http://www.twitter.com/' . $twitter . '" target="_blank">@' . $twitter . '</a></p>'; } echo '</div><div class="one-half">'; echo '<h2><a href="' . get_permalink() . '">' . get_the_title() . '</a></h2>'; the_content(); echo '</div></div>'; } } wp_reset_query(); }
/** * Adds sponsors shortcode * */ function _sbcg_sponsors($atts, $content = '') { $args = shortcode_atts(array('id' => ''), $atts); $out = null; $posts = array(); // If a id is specified get that sponsor. if (!empty($args['id'])) { $posts[] = get_post($args['id']); // Otherwise loop over all active sponsors. } else { $query = new WP_Query(array('post_type' => '_sbcg_sponsors', 'post_status' => 'publish', 'posts_per_page' => -1, 'caller_get_posts' => 1, 'order' => 'ASC', 'orderby' => 'title')); if ($query->have_posts()) { while ($query->have_posts()) { $query->the_post(); $posts[] = get_post(); } } wp_reset_query(); } foreach ($posts as $post) { $url = get_post_meta($post->ID, '_sbcg_sponsors_value_key', true); $out .= sprintf(empty($args['id']) ? "\n<li class=\"sponsor\">%s%s%s</li>" : "\n<div class=\"sponsor-single\">%s%s%s</div>", $url ? "<a href=\"{$url}\">" : "", has_post_thumbnail($post->ID) ? "<img src=\"" . wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'medium')[0] . "\" alt=\"" . get_the_title($post->ID) . "\">" : get_the_title($post->ID), $url ? "</a>" : ""); } $out .= "\n"; if (empty($args['id'])) { return "<ul class=\"sponsors\">{$out}</ul>"; } return $out; }
function zp_custom_blog_page() { global $post, $paged; $include = genesis_get_option('blog_cat'); $exclude = genesis_get_option('blog_cat_exclude') ? explode(',', str_replace(' ', '', genesis_get_option('blog_cat_exclude'))) : ''; if (get_query_var('paged')) { $paged = get_query_var('paged'); } elseif (get_query_var('page')) { $paged = get_query_var('page'); } else { $paged = 1; } //* Arguments $args = array('cat' => $include, 'category__not_in' => $exclude, 'posts_per_page' => genesis_get_option('blog_cat_num'), 'paged' => $paged); query_posts($args); if (have_posts()) { while (have_posts()) { the_post(); do_action('genesis_before_entry'); printf('<article %s>', genesis_attr('entry')); // check post format and call template $format = get_post_format(); get_template_part('content', $format); do_action('genesis_after_entry_content'); //do_action( 'genesis_entry_footer' ); echo '</article>'; do_action('genesis_after_entry'); } } //* Genesis navigation genesis_posts_nav(); //* Restore original query wp_reset_query(); }
function show_category($cid = 1) { $args = array('showposts' => 4, 'cat' => $cid, 'orderby' => 'post_date', 'order' => 'desc'); query_posts($args); global $the_post; $category = ''; while (have_posts()) { the_post(); $cat = get_the_category(get_the_ID()); $link = get_permalink(get_the_ID()); $src = get_the_post_thumbnail(get_the_ID(), 'index_thumb'); $c_name = $cat[0]->name; $title = get_the_title(); echo $category .= <<<EOF <div class="box"> <a href="{$link}"> <div class="boximg">{$src}</div> <div class="category">{$c_name}</div> <p>{$title}</p> </a> </div> EOF; } wp_reset_query(); return $category; }
public static function friend_list_func($atts, $content = "") { $atts = shortcode_atts(array('per_page' => '100'), $atts, 'friend_list'); $return = ""; query_posts(array('post_type' => 'friend', 'showposts' => $atts['per_page'], 'meta_query' => array('relation' => 'AND', array('key' => 'avatar150', 'value' => 'https://static0.fitbit.com/images/profile/defaultProfile_100_male.gif', 'compare' => 'NOT LIKE'), array('key' => 'avatar150', 'value' => 'https://static0.fitbit.com/images/profile/defaultProfile_100_female.gif', 'compare' => 'NOT LIKE')))); if (have_posts()) { while (have_posts()) { the_post(); $displayName = get_post_meta(get_the_id(), 'displayName', true); $avatar = get_post_meta(get_the_id(), 'avatar150', true); $return .= sprintf('<div class="col-lg-3 col-sm-3 focus-box"> <div class="service-icon"> <i style="background:url(%s) no-repeat center;width:100%%; height:100%%;" class="pixeden"></i> </div> <h3 class="red-border-bottom">%s</h3> <a class="btn btn-primary btn-block green-btn btn-sm" href="https://www.fitbit.com/user/%s"><i class="fa fa-plus"></i> Add Friend</a> <br/> </div>', $avatar, $displayName, get_the_title(), get_the_content()); } $return = '<div class="hwd-wrapper"><div class="row">' . $return . '</div></div>'; } else { $return = 'No Friends Found'; } wp_reset_query(); return $return; }
/** @see WP_Widget::widget */ function widget($args, $instance) { extract($args); echo $before_widget; $a = array("orderby" => "id", "order" => "asc"); $categories = get_categories($a); foreach ($categories as $category) { echo $before_title; // var_dump($category); echo "<h2>" . $category->name . "</h2><ul>"; global $post; $args = array('category' => $category->term_id, "numberposts" => -1, "orderby" => "title", "order" => "ASC"); $myposts = get_posts($args); foreach ($myposts as $post) { setup_postdata($post); ?> <li><a href="<?php the_permalink(); ?> "><?php the_title(); ?> </a></li><?php } echo "</ul>"; wp_reset_query(); echo $after_title; } echo $after_widget; }
public function get_post_count($post_type = 'item') { $author_args = array('post_status' => 'publish', 'post_type' => $post_type, 'author' => $this->author->ID); $author_posts = query_posts($author_args); wp_reset_query(); return count($author_posts); }
/** * Display widget content. * * @param array $args Display arguments including before_title, after_title, before_widget, and after_widget. * @param array $instance The settings for the particular instance of the widget */ function widget($args, $instance) { extract($args); $instance = wp_parse_args((array) $instance, $this->defaults); $featured_page = new WP_Query(array('page_id' => $instance['page_id'])); echo $before_widget . '<div class="feature-page">'; if (!empty($instance['title'])) { echo $before_title . apply_filters('widget_title', $instance['title'], $instance, $this->id_base) . $after_title; } if ($featured_page->have_posts()) { while ($featured_page->have_posts()) { $featured_page->the_post(); echo '<div class="' . implode(' ', get_post_class()) . '">'; if (!empty($instance['show_title'])) { printf('<h4 class="entry-title"><a href="%s" title="%s">%s</a></h4>', get_permalink(), the_title_attribute('echo=0'), get_the_title()); } //Show image if (!empty($instance['show_image'])) { printf('<a href="%s" title="%s" class="%s">%s</a>', get_permalink(), the_title_attribute('echo=0'), esc_attr($instance['image_alignment']), calibrefx_get_image(array('format' => 'html', 'size' => $instance['image_size']))); } if (!empty($instance['show_content'])) { if (empty($instance['content_limit'])) { the_content($instance['more_text']); } else { the_content_limit((int) $instance['content_limit'], esc_html($instance['more_text'])); } } echo '</div><!--end post_class()-->' . "\n\n"; } } echo '</div>' . $after_widget; wp_reset_query(); }
function widget($args, $instance) { extract($args); global $socialProfiles; /* Our variables from the widget settings. */ $title = apply_filters('widget_title', $instance['title']); echo $before_widget; echo $before_title . $title . $after_title; ?> <ul class="social"> <?php foreach ($socialProfiles as $item) { $id = strtolower($item); $iditem = $id . "_title"; $iddesc = $id . "_desc"; if ($instance[$id] && $instance[$id] != '') { if (simple_email_check($instance[$id])) { $instance[$id] = 'mailto:' . $instance[$id]; } echo '<li><a class="' . $id . '" href="' . $instance[$id] . '" rel="external,nofollow" title="' . $instance[$iditem] . '"><img src="' . get_bloginfo('template_directory') . '/images/icons/' . strtolower($item) . '.png" alt="' . $instance[$iddesc] . '" />' . $instance[$iditem] . '<span>' . $instance[$iddesc] . '</span></a></li>'; } } ?> </ul> <div class="cleaner"> </div> <?php echo $after_widget; wp_reset_query(); }
/** * Outputs the Twitter Card code on singular pages. * * @return void Only shows on singular pages, false on non-singular pages. */ public function twitter() { wp_reset_query(); $this->type(); $this->site_twitter(); $this->site_domain(); $this->author_twitter(); if ('summary_large_image' === $this->options['twitter_card_type']) { $this->image(); } // No need to show these when OpenGraph is also showing, as it'd be the same contents and Twitter // would fallback to OpenGraph anyway. if ($this->options['opengraph'] === false) { if ('summary' === $this->options['twitter_card_type']) { $this->image(); } $this->twitter_description(); $this->twitter_title(); $this->twitter_url(); } /** * Action: 'wpseo_twitter' - Hook to add all WP SEO Twitter output to so they're close together. */ do_action('wpseo_twitter'); }
function shortcode_faqs($atts, $content = null) { extract($atts = shortcode_atts(array('counts' => '12', 'cats' => '', 'posts' => '', 'order' => 'DESC', 'orderby' => 'date', 'filter' => 'yes', 'post_type' => 'faq', 'taxonomy' => 'faq_cat'), $atts)); // Get Query $query = new Twoot_Query(array('counts' => $counts, 'cats' => $cats, 'posts' => $posts, 'order' => $order, 'orderby' => $orderby, 'post_type' => $post_type, 'taxonomy' => $taxonomy)); $grid = new Twoot_Template_Grid(); $do_query = new WP_Query($query->do_template_query()); $faqs_class = $filter == 'yes' ? 'column nine' : 'twelve'; $html = '<div class="the-faq-list shortcode-toggle outer clearfix">' . "\n"; if ($filter == 'yes') { $html .= '<div class="column three">'; $html .= $grid->filter_terms_menu($do_query->posts, $atts); $html .= '</div>'; } $html .= '<div id="faqs" class="' . $faqs_class . '">'; while ($do_query->have_posts()) { $do_query->the_post(); //Get terms class $terms_class = $grid->filter_terms_class(get_the_ID(), $atts); $html .= '<div class="tog-item faq-item inner ' . $terms_class . '">'; $html .= '<a href="#" class="tog"><i class="icon twoot-icon"></i>' . get_the_title() . '</a>'; $html .= '<div class="tog-content clearfix">' . do_shortcode(get_the_content()) . '</div>'; $html .= '</div>'; } wp_reset_query(); $html .= '</div>'; $html .= '</div>'; return $html; }
function blog_summary_shortcode($attr) { // Describes what attributes to parse from shortcode; only 'count' extract(shortcode_atts(array('count' => '5', 'grouptag' => 'ul', 'entrytag' => 'li', 'titletag' => 'h4', 'datetag' => 'span', 'commentstag' => 'span', 'summarytag' => 'div'), $attr)); // Queries to populate our loop based on shortcode count attribute $r = new WP_Query("showposts={$count}&what_to_show=posts&nopaging=0&post_status=publish"); // Only run if we have posts; can't run this through searches if ($r->have_posts() && !is_search()) { // If we're using a Sandbox-friendly theme . . . if (function_exists('sandbox_body_class')) { // We can't have double hfeed classes, otherwise it won't parse $groupclasses = 'xoxo'; } else { // Otherwise, use hfeed to ensure hAtom compliance $groupclasses = 'xoxo hfeed'; } // Begin the output for shortcode and inserts in the group tag what classes we have $output = '<' . $grouptag . ' class="' . $groupclasses . '">'; // Begins our loop for returning posts while ($r->have_posts()) { // Sets which post from our loop we're at $r->the_post(); // Allows the_date() with multiple posts within a single day unset($previousday); // If we're using a Sandbox-friendly theme . . . if (function_exists('sandbox_post_class')) { // Let's use semantic classes with each entry element $entryclasses = sandbox_post_class(false); } else { // Otherwise, use hentry to ensure hAtom compliance $entryclasses = 'hentry'; } // Begin entry wrapper and inserts what classes we got from above $output .= "\n" . '<' . $entrytag . ' class="' . $entryclasses . '">'; // Post title $output .= "\n" . '<' . $titletag . ' class="entry-title"><a href="' . get_permalink() . '" title="' . sprintf(__('Permalink to %s', 'blog_summary'), the_title_attribute('echo=0')) . '" rel="bookmark">' . get_the_title() . '</a></' . $titletag . '>'; // Post date with hAtom support $output .= "\n" . '<' . $datetag . ' class="entry-date"><abbr class="published" title="' . get_the_time('Y-m-d\\TH:i:sO') . '">' . sprintf(__('%s', 'blog_summary'), the_date('', '', '', false)) . '</abbr></' . $datetag . '>'; // Comments number $output .= "\n" . '<' . $commentstag . ' class="entry-comments"><a href="' . get_permalink() . '#comments" title="' . sprintf(__('Comments to %s', 'blog_summary'), the_title_attribute('echo=0')) . '">' . sprintf(__('Comments (%s)', 'blog_summary'), apply_filters('comments_number', get_comments_number())) . '</a></' . $commentstag . '>'; // Post excerpt with hAtom support $output .= "\n" . '<' . $summarytag . ' class="entry-summary">' . "\n" . apply_filters('the_excerpt', get_the_excerpt()) . '</' . $summarytag . '>'; // Close each post LI $output .= "\n" . '</' . $entrytag . '>'; // Finish the have_posts() query } // while ( $r->have_posts() ) : // Close the parent UL $output .= "\n" . '</' . $grouptag . '>'; // Rewinds loop from $r->the_post(); rewind_posts(); // End the initial IF statement } // if ( $r->have_posts() ) : // Clears our query to put the loop back where it was wp_reset_query(); // $r = new WP_Query() // Returns $output to the shortcode return $output; }
/** * Render all the ajax comments */ function siteorigin_ajax_comments_ajax_comment_rerender($location, $comment) { if (empty($_POST['is_ajax'])) { return $location; } $post_id = isset($_POST['comment_post_ID']) ? intval($_POST['comment_post_ID']) : ''; // We're going to pretend this is a single $query = array('post_id' => $post_id); if (get_option('page_comments')) { $args['per_page'] = get_option('comments_per_page'); $cpage = get_page_of_comment($comment->comment_ID, $args); $query['cpage'] = $cpage; } // Prevents a conflict with older versions of Page Builder. remove_filter('the_posts', 'siteorigin_panels_prepare_post_content'); query_posts($query); global $wp_query; $wp_query->is_single = true; $wp_query->is_singular = true; ob_start(); comments_template(); $comment_html = ob_get_clean(); wp_reset_query(); echo json_encode(array('status' => 'success', 'html' => $comment_html)); exit; }
function most_viewed() { ob_start(); $posts = wmp_get_popular(array('limit' => 4, 'post_type' => 'paper', 'range' => 'all_time')); global $post; if (count($posts) > 0) { foreach ($posts as $post) { setup_postdata($post); ?> <li><a href="<?php the_permalink(); ?> "> <?php if (get_field('short_title')) { the_field('short_title'); } else { the_title(); } ?> </a></li> <?php } } wp_reset_query(); $contents = ob_get_contents(); ob_end_clean(); return $contents; }
function jigoshop_product_tag($attributes) { global $paged; $jigoshop_options = Jigoshop_Base::get_options(); $attributes = shortcode_atts(array('tag' => '', 'per_page' => $jigoshop_options->get('jigoshop_catalog_per_page'), 'columns' => $jigoshop_options->get('jigoshop_catalog_columns'), 'orderby' => $jigoshop_options->get('jigoshop_catalog_sort_orderby'), 'order' => $jigoshop_options->get('jigoshop_catalog_sort_direction'), 'pagination' => false, 'tax_operator' => 'IN'), $attributes); if (isset($_REQUEST['tag'])) { $attributes['tag'] = $_REQUEST['tag']; } /** Operator validation. */ if (!in_array($attributes['tax_operator'], array('IN', 'NOT IN', 'AND'))) { $tax_operator = 'IN'; } /** Multiple category values. */ if (!empty($slug)) { $slug = explode(',', esc_attr($slug)); $slug = array_map('trim', $slug); } $args = array('post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'posts_per_page' => $attributes['per_page'], 'orderby' => $attributes['orderby'], 'order' => $attributes['order'], 'paged' => $paged, 'meta_query' => array(array('key' => 'visibility', 'value' => array('catalog', 'visible'), 'compare' => 'IN')), 'tax_query' => array(array('taxonomy' => 'product_tag', 'field' => 'slug', 'terms' => $attributes['tag'], 'operator' => $attributes['tax_operator']))); query_posts($args); ob_start(); jigoshop_get_template_part('loop', 'shop'); if ($attributes['pagination']) { do_action('jigoshop_pagination'); } wp_reset_query(); return ob_get_clean(); }
function efs_get_slider() { /**Options Array...to be added on admin later...*/ $showTitle = true; $showText = true; $beforeTitle = "<strong>"; $afterTitle = "</strong>"; $slider = '<div class="flexslider contain"> <ul class="slides">'; $efs_query = "post_type=slider-image"; query_posts($efs_query); if (have_posts()) { while (have_posts()) { the_post(); $img = get_the_post_thumbnail($post->ID, 'large'); $slider .= '<li>' . $img; if ($showTitle || $showText) { $slider .= '<p class="flex-caption">'; $slider .= $showTitle ? $beforeTitle . get_the_title() . $afterTitle : ''; $slider .= $showText ? '<br/>' . get_the_content() : ''; $slider .= '</p>'; } $slider .= '</li>'; } } wp_reset_query(); $slider .= '</ul> </div>'; return $slider; }
function widget($args, $instance) { global $post; extract($args, EXTR_SKIP); echo $before_widget; $title = empty($instance['title']) ? __('Recent Posts', 'lan-thinkupthemes') : apply_filters('widget_title', $instance['title']); if (!empty($title)) { echo $before_title . $title . $after_title; } $posts = new WP_Query('orderby=date&posts_per_page=' . $instance['postcount'] . ''); while ($posts->have_posts()) { $posts->the_post(); // Insert post date if needed. if ($instance['postdate'] == 'on') { $date_input = '<a href="' . get_permalink() . '" class="date">' . get_the_date('M j, Y') . '</a>'; } // HTML output echo '<div class="recent-posts">'; if (has_post_thumbnail() and $instance['imageswitch'] == 'on') { echo '<div class="image">', '<a href="' . get_permalink() . '" title="' . get_the_title() . '">' . get_the_post_thumbnail($post->ID, array(65, 65)) . '<div class="image-overlay"></div></a>', '</div>', '<div class="main">', '<a href="' . get_permalink() . '">' . get_the_title() . '</a>', $date_input, '</div>'; } else { echo '<div class="main">', '<a href="' . get_permalink() . '">' . get_the_title() . '</a>', $date_input, '</div>'; } echo '</div>'; } wp_reset_query(); echo $after_widget; }