function widget($args, $instance) { extract($args, EXTR_SKIP); echo $before_widget . $before_title; echo ec3_widget_title($instance['title'], 'Upcoming Events'); echo $after_title; if (ec3_check_installed(__('Upcoming Events', 'ec3'))) { // Parse $limit: // NUMBER - limits number of posts // NUMBER days - next NUMBER of days $limit = $instance['limit']; $num = intval($limit); $query = new WP_Query(); if (preg_match('/^ *([0-9]+) *d(ays?)?/', $limit, $matches)) { $query->query('ec3_days=' . intval($matches[1])); } elseif ($num > 0) { $query->query('ec3_after=today&posts_per_page=' . $num); } elseif ($num < 0) { $query->query('ec3_before=today&order=asc&posts_per_page=' . abs($num)); } else { $query->query('ec3_after=today&posts_per_page=5'); } echo "<ul class='ec3_events'>"; echo '<!-- Generated by Event-Calendar v' . ec3_get_version() . ' -->' . "\n"; if ($query->have_posts()) { $current_date = false; for ($evt = ec3_iter_all_events_q($query); $evt->valid(); $evt->next()) { // Date changed? $date = ec3_get_date(); if (!$current_date || $current_date != $date) { if ($current_date) { echo "</ul></li>\n"; } echo "<li class='ec3_list ec3_list_day'>{$date}:\n<ul>\n"; $current_date = $date; } // Print the event. echo ' <li><a href="' . get_permalink() . '">' . get_the_title() . ' (' . ec3_get_start_time() . ')</a></li>' . "\n"; } if ($current_date) { echo "</ul></li>\n"; } } else { echo "<li>" . __('No events.', 'ec3') . "</li>\n"; } echo "</ul>\n"; } echo $after_widget; }
/** * Retrieves a list of progress posts matching criteria * * If you try to use this function, you will need to implement your own switch_to_blog and wp_reset_postdata() handling if running in a multisite * and in a dpa_is_running_networkwide() configuration, otherwise the data won't be fetched from the appropriate site. * * @param array|string $args All the arguments supported by {@link WP_Query}, and some more. * @return array Posts * @since Achievements (3.0) */ function dpa_get_progress($args = array()) { $defaults = array('no_found_rows' => true, 'order' => 'DESC', 'orderby' => 'date', 'post_type' => dpa_get_progress_post_type(), 'posts_per_page' => -1, 'post_status' => array(dpa_get_locked_status_id(), dpa_get_unlocked_status_id())); $args = dpa_parse_args($args, $defaults, 'get_progress'); $progress = new WP_Query(); return apply_filters('dpa_get_progress', $progress->query($args), $args); }
/** * * * * * @since 1.0.9 * */ function _top_ajax_search() { if (STInput::request('action') != 'st_top_ajax_search') { return; } //Small security check_ajax_referer('st_search_security', 'security'); $s = STInput::get('s'); $arg = array('post_type' => array('post', 'st_hotel', 'st_rental', 'location', 'st_tours', 'st_holidays', 'st_cars', 'st_activity'), 'posts_per_page' => 10, 's' => $s, 'suppress_filters' => false); $query = new WP_Query(); $query->is_admin = false; $query->query($arg); $r = array(); while ($query->have_posts()) { $query->the_post(); $post_type = get_post_type(get_the_ID()); $obj = get_post_type_object($post_type); $item = array('title' => get_the_title(), 'id' => get_the_ID(), 'type' => $obj->labels->singular_name, 'url' => get_permalink(), 'obj' => $obj); if ($post_type == 'location') { $item['url'] = home_url(esc_url_raw('?s=&post_type=st_hotel&location_id=' . get_the_ID())); } $r['data'][] = $item; } wp_reset_query(); echo json_encode($r); die; }
function get_subpages($page_name) { $my_wp_query = new WP_Query(); $all_wp_pages = $my_wp_query->query(array('post_type' => 'page')); $pg = get_page_by_title($page_name); return get_page_children($pg->ID, $all_wp_pages); }
function recentPosts() { $rPosts = new WP_Query(); $rPosts->query('showposts=4'); while ($rPosts->have_posts()) { $rPosts->the_post(); ?> <div class="col-md-3 prj-item col-sm-6"> <a href="<?php the_permalink(); ?> "> <?php the_post_thumbnail('recent-thumbnails'); ?> <div class="info"> <i class="fa fa-plus"></i> <h5><?php the_title(); ?> </h5> <!--<h6> cats </h6> --> </div> </a> </div> <?php } wp_reset_query(); }
function myLoop($atts, $content = null) { extract(shortcode_atts(array("pagination" => 'true', "query" => '', "category" => ''), $atts)); global $wp_query, $paged, $post; $temp = $wp_query; $wp_query = null; $wp_query = new WP_Query(); $query .= 'post_type=person'; $wp_query->query($query); ob_start(); ?> <?php while ($wp_query->have_posts()) { $wp_query->the_post(); ?> <?php get_template_part('content', get_post_type()); ?> <?php } ?> <?php $wp_query = null; $wp_query = $temp; $content = ob_get_contents(); ob_end_clean(); return $content; }
protected function addPopupByURL($matches) { global $wp_query; $pageId = $matches[1]; if (is_numeric($pageId)) { $post = get_post($pageId); } else { $query = new WP_Query(); //simulate category query in order to fool ACE $temp = $wp_query->is_category; $wp_query->is_category = true; $posts = $query->query(array('name' => $pageId)); $wp_query->is_category = $temp; if (empty($posts)) { return "#error-popup-{$pageId}"; } $post = $posts[0]; } if (!$post) { return "#error-popup-{$pageId}"; } $this->replaceHappened = true; $this->content[$post->ID] = '<div class="popup-content">' . apply_filters('the_content', $post->post_content) . '</div>'; return '#popup" onclick="return showPopup(\'' . $post->ID . '\')'; }
/** * Performs post queries for internal linking. * * @since 3.1.0 * * @param array $args Optional. Accepts 'pagenum' and 's' (search) arguments. * @return array Results. */ function wp_link_query($args = array()) { $pts = get_post_types(array('publicly_queryable' => true), 'objects'); $pt_names = array_keys($pts); $query = array('post_type' => $pt_names, 'suppress_filters' => true, 'update_post_term_cache' => false, 'update_post_meta_cache' => false, 'post_status' => 'publish', 'order' => 'DESC', 'orderby' => 'post_date', 'posts_per_page' => 20); $args['pagenum'] = isset($args['pagenum']) ? absint($args['pagenum']) : 1; if (isset($args['s'])) { $query['s'] = $args['s']; } $query['offset'] = $args['pagenum'] > 1 ? $query['posts_per_page'] * ($args['pagenum'] - 1) : 0; // Do main query. $get_posts = new WP_Query(); $posts = $get_posts->query($query); // Check if any posts were found. if (!$get_posts->post_count) { return false; } // Build results. $results = array(); foreach ($posts as $post) { if ('post' == $post->post_type) { $info = mysql2date(__('Y/m/d'), $post->post_date); } else { $info = $pts[$post->post_type]->labels->singular_name; } $results[] = array('ID' => $post->ID, 'title' => trim(esc_html(strip_tags(get_the_title($post)))), 'permalink' => get_permalink($post->ID), 'info' => $info); } return $results; }
/** * Get a collection of posts. * * @param WP_REST_Request $request Full details about the request. * @return WP_Error|WP_REST_Response */ public function get_items($request) { $args = array(); $args['author'] = $request['author']; $args['paged'] = $request['page']; $args['posts_per_page'] = $request['per_page']; $args['post_parent'] = $request['parent']; $args['post_status'] = $request['status']; $args['s'] = $request['search']; if (is_array($request['filter'])) { $args = array_merge($args, $request['filter']); unset($args['filter']); } // Force the post_type argument, since it's not a user input variable. $args['post_type'] = $this->post_type; /** * Filter the query arguments for a request. * * Enables adding extra arguments or setting defaults for a post * collection request. * * @param array $args Key value array of query var to query value. * @param WP_REST_Request $request The request used. */ $args = apply_filters('rest_post_query', $args, $request); $query_args = $this->prepare_items_query($args); $posts_query = new WP_Query(); $query_result = $posts_query->query($query_args); $posts = array(); foreach ($query_result as $post) { if (!$this->check_read_permission($post)) { continue; } $data = $this->prepare_item_for_response($post, $request); $posts[] = $this->prepare_response_for_collection($data); } $response = rest_ensure_response($posts); $count_query = new WP_Query(); unset($query_args['paged']); $query_result = $count_query->query($query_args); $total_posts = $count_query->found_posts; $response->header('X-WP-Total', (int) $total_posts); $max_pages = ceil($total_posts / $request['per_page']); $response->header('X-WP-TotalPages', (int) $max_pages); $base = add_query_arg($request->get_query_params(), rest_url('/wp/v2/' . $this->get_post_type_base($this->post_type))); if ($request['page'] > 1) { $prev_page = $request['page'] - 1; if ($prev_page > $max_pages) { $prev_page = $max_pages; } $prev_link = add_query_arg('page', $prev_page, $base); $response->link_header('prev', $prev_link); } if ($max_pages > $request['page']) { $next_page = $request['page'] + 1; $next_link = add_query_arg('page', $next_page, $base); $response->link_header('next', $next_link); } return $response; }
function shortcode_list_posts($atts, $content = null) { extract(shortcode_atts(array('posts_per_page' => -1, 'cat' => '', 'tag' => '', 'order' => '', 'order_by' => ''), $atts)); $args = array('post_type' => 'post', 'posts_per_page' => $posts_per_page, 'post_status' => 'publish'); if (!empty($cat)) { $cat = split(',', str_replace(" ", "", $cat)); $args['category__and'] = $cat; } if (!empty($tag)) { $tag = split(',', str_replace(" ", "", $tag)); $args['tag__in'] = $tag; } if ($order) { $args['order'] = $order; } if ($order_by) { $args['orderby'] = $order_by; } $my_query = new WP_Query(); $my_query->query($args); $content = '<ul class="post-list" >'; while ($my_query->have_posts()) { $my_query->the_post(); $author = get_the_author_meta('display_name'); $author_url = get_author_posts_url(get_the_author_meta('ID')); $content .= '<li><a href="' . get_permalink() . '" title="' . get_the_title() . '">' . get_the_title() . '</a> <span>- by <a href="' . $author_url . '" title="' . $author . '">' . $author . '</a> on ' . get_the_time('F j, Y') . '</span></li>' . "\n"; } $content .= '</ul><!-- end .post-list -->'; //wp_reset_query(); return remove_wpautop($content); }
function widget($args, $instance) { global $post; extract($args, EXTR_SKIP); echo $before_widget; $title = empty($instance['title']) ? '' : apply_filters('widget_title', $instance['title']); if (!empty($title)) { echo $before_title . $title . $after_title; } if ((is_home() || is_front_page()) && !is_paged() && !ceo_pluginfo('disable_comic_on_home_page')) { $chapter_on_home = ''; $chapter_on_home = get_term_by('id', ceo_pluginfo('chapter_on_home'), 'chapters'); $chapter_on_home = !is_wp_error($chapter_on_home) && !empty($chapter_on_home) ? '&chapters=' . $chapter_on_home->slug : ''; $order = ceo_pluginfo('display_first_comic_on_home_page') ? 'asc' : 'desc'; $query_args = 'post_type=comic&showposts=1&order=' . $order . $chapter_on_home; apply_filters('ceo_display_comic_mininav_home_query', $query_args); $comicFrontpage = new WP_Query(); $comicFrontpage->query($query_args); while ($comicFrontpage->have_posts()) { $comicFrontpage->the_post(); ceo_list_jump_to_comic($instance['exclude'], false); } } elseif (!empty($post)) { ceo_list_jump_to_comic($instance['exclude'], false); } echo $after_widget; }
function ut_get_posts_children_ids($parent_id) { /* id is empty , we leave here */ if (empty($parent_id)) { return array(); } $children_array = array(); $child_query = new WP_Query(); $children = $child_query->query(array('post_type' => 'page', 'order' => 'ASC', 'post_status' => 'publish', 'orderby' => 'menu_order', 'post_parent' => $parent_id)); if (!empty($children)) { foreach ($children as $child) { /* push current child into array */ $children_array[] = $child->ID; /* recursive - here we go! */ $gchildren = ut_get_posts_children_ids($child->ID); if (!empty($gchildren)) { foreach ($gchildren as $gchild) { $children_array[] = $gchild; } } } } wp_reset_postdata(); return !empty($children_array) ? $children_array : array(); }
/** * Search for publications. * * @param array $args * @return array */ private function publication_query($args = array()) { $query = array('post_type' => 'seoslides-slideset', 'suppress_filters' => true, 'update_post_term_cache' => false, 'update_post_meta_cache' => false, 'post_status' => 'publish', 'order' => 'DESC', 'orderby' => 'post_date', 'posts_per_page' => 20); $args['pagenum'] = isset($args['pagenum']) ? absint($args['pagenum']) : 1; if (isset($args['s'])) { $query['s'] = $args['s']; } $query['offset'] = $args['pagenum'] > 1 ? $query['posts_per_page'] * ($args['pagenum'] - 1) : 0; // Run the query $get_posts = new WP_Query(); $posts = $get_posts->query($query); $results = array(); if (0 === $get_posts->post_count) { return $results; } // Populate results foreach ($posts as $post) { // Get the embed ID for the first slide in the presentation $slideset = new SEOSlides_Slideset($post->ID); /** @var SEOSlides_Embed $embed */ $embed = SEOSlides_Module_Provider::get('SEOSlides Embed'); $embed_id = $embed->get_embed_unique_id($post->ID, $slideset->first_slide()->slug); $embed_url = $embed->get_embed_url($post->ID, $slideset->first_slide()->slug); $shortcode = '[seoslides embed_id="' . $embed_id . '"'; $shortcode .= ' script_src="' . preg_replace('/\\/(slides|embeds)\\//', '/embed-script/', $embed_url) . '"'; $shortcode .= ' overview_src="' . get_permalink($post) . '"'; $shortcode .= ' title="' . get_the_title($post) . '"'; $shortcode .= ' site_src="' . get_home_url() . '"'; $shortcode .= ' site_title="' . get_bloginfo('name') . '"'; $shortcode .= ' /]'; $results[] = array('ID' => $post->ID, 'title' => trim(esc_html(strip_tags(get_the_title($post)))), 'shortcode' => esc_attr($shortcode), 'info' => mysql2date(__('Y/m/d'), $post->post_date)); } return $results; }
function choosepopup_inner_custom_box() { // Use nonce for verification wp_nonce_field(plugin_basename(__FILE__), 'choosepopup_noncename'); $popup_list = new WP_Query(); $popup_list->query(array('post_status' => 'publish', 'post_type' => array('post', 'page'), 'order_by' => 'menu_order, post_title', 'posts_per_page' => '-1')); //print_r($popup_list); if (!empty($popup_list)) { $meta_values = get_post_meta($_GET['post'], 'popup', true); echo '<label for="choosepopup_new_field">' . __("Popup post", 'choosepopup_textdomain') . '</label> '; echo '<input name="choosepopup_new_field" id="choosepopup_new_field" value="' . $meta_values . '" />'; /* echo '<option></option>'; foreach ($popup_list->posts as $q) { if (intval($q->ID) > 0) echo '<option value="' . $q->ID . '"'; if (intval($q->ID) > 0 && intval($q->ID) == $meta_values) echo ' selected'; if (intval($q->ID) > 0) echo '>' . $q->post_title . ' '. ucfirst($q->post_type) . '</option>'; } echo '</select>'; */ $anc_values = get_post_meta($_GET['post'], 'anchor', true); echo '<br /><label for="chooseanchor_new_field">Popup anchor</label> '; echo '<input name="chooseanchor_new_field" id="chooseanchor_new_field" type="text" value="' . $anc_values . '"/>'; } }
function get_my_page_by_title($title) { $my_wp_query = new WP_Query(); $all_wp_pages = $my_wp_query->query(array('post_type' => 'page')); $page = get_page_by_title($title); return $page; }
function tpp_posts_widget() { $tpp_posts_query = new WP_Query(); $tpp_posts_query->query('&posts_per_page=10&orderby=comment_count&order=DESC'); ?> <h3>Posts on this page:</h3> <?php if ($tpp_posts_query->have_posts()) { while ($tpp_posts_query->have_posts()) { $tpp_posts_query->the_post(); ?> <a href="<?php echo the_permalink(); ?> " title="<?php echo the_title(); ?> "><?php echo the_title(); ?> </a> (<?php echo comments_number(); ?> ) <br /> <?php } } ?> <?php }
function widget($args, $instance) { extract($args); $title = apply_filters('widget_title', $instance['title']); $show = $instance['show']; global $post, $wpdb; $themePath = THB_THEME_ROOT; $pop = new WP_Query(); $pop->query('showposts=' . $show . ''); echo $before_widget; echo $before_title; echo $title; echo $after_title; echo '<ul>'; while ($pop->have_posts()) { $pop->the_post(); ?> <li> <figure> <a href="<?php the_permalink(); ?> " rel="bookmark" title="<?php the_title(); ?> "> <?php if (has_post_thumbnail()) { the_post_thumbnail(); } else { ?> <img src="<?php echo THB_THEME_ROOT; ?> /assets/img/nothumb.jpg" alt="No Post Image for <?php the_title(); ?> " width="40" height="40" /> <?php } ?> </a> </figure> <a href="<?php the_permalink(); ?> " rel="bookmark" title="<?php the_title(); ?> " class="postlink"><?php the_title(); ?> </a> </li> <?php } echo '</ul>'; echo $after_widget; wp_reset_query(); }
function blogAjaxPagination() { global $smof_data, $us_thumbnail_size; $thumbnail_sizes = array('blog-big', 'blog-grid', 'blog-small'); if (isset($_POST['type']) and in_array($_POST['type'], $thumbnail_sizes)) { $us_thumbnail_size = $_POST['type']; } else { $us_thumbnail_size = 'blog-grid'; } $page = isset($_POST['page']) ? (int) $_POST['page'] : 1; if ($page < 1) { $page = 1; } $args = array('post_type' => 'post', 'post_status' => 'publish', 'orderby' => 'date', 'order' => 'DESC', 'paged' => $page); $_items = isset($_POST['items']) ? (int) $_POST['items'] : NULL; if ($_items !== NULL and $_items > 0) { $args['posts_per_page'] = $_items; } $categories_slugs = null; if (!empty($_POST['category'])) { $categories_slugs = explode(',', sanitize_text_field($_POST['category'])); $args['tax_query'] = array(array('taxonomy' => 'category', 'field' => 'slug', 'terms' => $categories_slugs)); } $wp_query = new WP_Query(); $lang_param = ''; if (defined('ICL_LANGUAGE_CODE')) { $args['lang'] = ICL_LANGUAGE_CODE; } $wp_query->query($args); while ($wp_query->have_posts()) { $wp_query->the_post(); get_template_part('templates/blog_single_post_ajax'); } die; }
/** * */ public static function pricetable($atts, $content = null, $code = null) { if ($atts == 'generator') { global $wpdb; $prices_list = array(); $pricetables = $wpdb->get_results('SELECT ID, post_title FROM ' . $wpdb->posts . ' WHERE post_type = "pricetable"'); if (is_array($pricetables)) { foreach ($pricetables as $key => $value) { $prices_list[$value->ID] = $pricetables[$key]->post_title; } } else { $price_list[0] = __('Please install Price Table plugin...', MISS_ADMIN_TEXTDOMAIN); } $option = array('name' => __('Blog Grid Layout', MISS_ADMIN_TEXTDOMAIN), 'value' => 'pricetable', 'options' => array(array('name' => __('Select Table', MISS_ADMIN_TEXTDOMAIN), 'desc' => __('Choose "Pricing Table" to use.', MISS_ADMIN_TEXTDOMAIN), 'id' => 'id', 'type' => 'select', 'options' => $prices_list), 'shortcode_has_atts' => true)); return $option; } extract(shortcode_atts(array('id' => ''), $atts)); $pricetable = new WP_Query(); $pricetable->query(array('post_type' => 'pricetable', 'post_id' => $id)); while ($pricetable->have_posts()) { $pricetable->the_post(); $prices_list[get_the_ID()] = get_the_title(); $out = '[price_table id="' . $id . '"]'; } return do_shortcode($out); }
public static function get_pins($args) { $defaults = array('numberposts' => 5, 'category' => 0, 'orderby' => 'date', 'order' => 'DESC', 'include' => array(), 'exclude' => array(), 'meta_key' => '', 'meta_value' => '', 'post_type' => 'pin', 'suppress_filters' => true); $p = wp_parse_args($args, $defaults); $get_pins = new WP_Query(); return $get_pins->query($p); }
public function prepare_items() { $paged = $this->get_pagenum(); $args = array('post_type' => 'json_consumer', 'post_status' => 'any', 'meta_query' => array(array('key' => 'type', 'value' => 'oauth1')), 'paged' => $paged); $query = new WP_Query(); $this->items = $query->query($args); }
public function query($args) { //make sure that the query params was not built before if (!isset($args['_mpp_mapped_query'])) { $args = self::build_params($args); } parent::query($args); }
/** * Get result. * * Works for all query types. * * @return array */ public function get_result() { if (!method_exists($this->query, 'query')) { return []; } $this->parse_args($this->args); return $this->query->query($this->get_query_args()); }
public static function at_recent_posts($atts = null, $content = null) { if ($atts == 'generator') { return array("name" => __("Recent Posts", AT_ADMIN_TEXTDOMAIN), "base" => "at_recent_posts", 'icon' => "im-icon-spinner-4", "class" => "at-resent-posts-class", 'category' => __("Theme Short-Codes", AT_ADMIN_TEXTDOMAIN), "params" => array(array("type" => "textfield", "heading" => __("Title", AT_ADMIN_TEXTDOMAIN), "param_name" => "title", "value" => "", "description" => __("Description will appear below each chart.", AT_ADMIN_TEXTDOMAIN), 'dependency' => array('element' => 'content_type', 'value' => array('custom_text'))), array("type" => "dropdown", "heading" => __("Post type", AT_ADMIN_TEXTDOMAIN), "param_name" => "post_type", "width" => 200, "value" => array("Posts" => "post", "News" => "news", "Reviews" => "reviews"), "description" => ''), array("type" => "range", "heading" => __("Limit", AT_ADMIN_TEXTDOMAIN), "param_name" => "limit", "default" => 12, "min" => 0, "max" => 20, "step" => 1, "unit" => '', "description" => __("Select limit to display on this block", AT_ADMIN_TEXTDOMAIN)), array("type" => "textfield", "heading" => __("Description length", AT_ADMIN_TEXTDOMAIN), "param_name" => "trim", "value" => "80", "description" => __("Enter truncated content length in symbols.", AT_ADMIN_TEXTDOMAIN)), array("type" => "range", "heading" => __("View post", AT_ADMIN_TEXTDOMAIN), "param_name" => "view_post", "default" => "3", "min" => "0", "max" => "4", "step" => "1", "unit" => '', "description" => __("Select limit to display on one row", AT_ADMIN_TEXTDOMAIN)), array('heading' => __("Hide <small>(optional)</small>", AT_ADMIN_TEXTDOMAIN), 'description' => __("You may hide away some screen items.", AT_ADMIN_TEXTDOMAIN), 'param_name' => "disable", 'value' => array(__("Date", AT_ADMIN_TEXTDOMAIN) => "date", __("Featured image", AT_ADMIN_TEXTDOMAIN) => "featured", __("Teaser", AT_ADMIN_TEXTDOMAIN) => "excerpt"), 'type' => 'checkbox'), array("type" => "textfield", "heading" => __("Extra class name", AT_ADMIN_TEXTDOMAIN), "param_name" => "el_class", "value" => "", "description" => __("If you wish to style particular content element differently, then use this field to add a class name and then refer to it in Custom CSS Shortcode or Masterkey Custom CSS option.", AT_ADMIN_TEXTDOMAIN)))); } $shortcode_id = self::_shortcode_id(); $view_post = 0; extract(shortcode_atts(array('title' => '', 'limit' => '3', 'trim' => 80, 'view_post' => '3', 'disable' => '', 'el_class' => '', 'width' => '1/1', 'post_type' => 'post'), $atts)); $width = wpb_translateColumnWidthToSpan($width); $cwidth = (100 - 2.5 * ($view_post - 1)) / $view_post; $query = array('post_type' => $post_type, 'showposts' => $limit, 'nopaging' => false, 'ignore_sticky_posts' => 1); $results = new WP_Query(); $results->query($query); $output = '<div class="recent_blog ">'; $output .= '<h2>' . $title . '</h2>'; $view_post = (int) $view_post; if ($results->have_posts()) { $c = 0; while ($results->have_posts()) { $c++; $class = "post_block"; $results->the_post(); $margin = 2.5; if ($c === $view_post) { $class .= ' last'; $margin = 0; } $output .= '<div class="' . $class . '" style="max-width: ' . $cwidth . '%; margin-right: ' . $margin . '%;">'; // Show featured image if (has_post_thumbnail() && strpos($disable, 'featured') === false) { // $car_model = AT_Loader::get_instance()->model('car_model'); // $cars = array(); // <a title="' . $title . '" href="' . get_permalink( $car['ID'] ) . '"><img src="' . AT_Common::static_url( $car['photo']['photo_path'] . 'original/' . $car['photo']['photo_name'] ) . '" alt="' . $title . '"/></a> $output .= '<a class="thumb" href="' . get_permalink() . '">' . get_the_post_thumbnail($post_id = get_the_ID(), $size = array(180, 180)); if (get_post_meta(get_the_ID(), '_featured_video', true)) { $output .= '<i class="icon-youtube-play has_video"></i>'; } $output .= '</a>'; } $output .= '<h5><a href="' . get_permalink() . '">' . strtoupper(get_the_title()) . '</a></h5>'; // Show date if (strpos($disable, 'date') === false) { $output .= '<div class="date">' . get_the_date() . '</div>'; } // Show teaser if (strpos($disable, 'excerpt') === false) { $output .= '<div class="post"><p>' . AT_Common::truncate($content = get_the_excerpt(), $limit = $trim) . '</p></div>'; } $output .= '</div>'; if ($c === $view_post) { $output .= '<div class="clear"></div>'; $c = 0; } } } $output .= '<div class="clear"></div></div>'; return $output; }
/** * Front-end display of widget. * * @see WP_Widget::widget() * * @param array $args Widget arguments. * @param array $instance Saved values from database. */ public function widget($args, $instance) { $title = apply_filters('widget_title', $instance['title']); echo $args['before_widget']; if (!empty($title)) { echo $args['before_title'] . $title . $args['after_title']; } global $md_theme_options; ?> <ul> <?php $rPosts = new WP_Query(); $rPosts->query('showposts=' . $instance['count']); while ($rPosts->have_posts()) { $rPosts->the_post(); ?> <?php $thumb = wp_get_attachment_image_src(get_post_thumbnail_id(), 'thumbnail'); ?> <li> <span class="date"><?php echo get_the_date(); ?> </span> <img src="<?php echo $thumb[0]; ?> " alt="<?php esc_attr(the_title()); ?> " class="" /> <h3><a href="<?php the_permalink(); ?> " title="<?php esc_attr(the_title()); ?> "><?php the_title(); ?> </a></h3> <p><?php echo substr(get_the_excerpt(), 0, 50) . '...'; ?> </p> </li> <?php } wp_reset_query(); ?> </ul> <?php echo $args['after_widget']; }
/** * Returns an array of pairs ID, title of entries of CPT * * @param string $type Custom Post Type to filter. * @return array */ function get_info_for_select($type) { $query = new WP_Query(); $args = array('post_type' => $type, 'post_status' => 'publish', 'no_found_rows' => true, 'posts_per_page' => -1); $results = $query->query($args); return array_map(function ($entry) { return array('value' => $entry->ID, 'title' => $entry->post_title); }, $results); }
/** * Returns an array of pairs ID, title of entries of CPT * * @return array */ function get_info_for_select() { $query = new WP_Query(); $args = array('post_type' => $this->type, 'post_status' => 'publish', 'no_found_rows' => true, 'posts_per_page' => -1); $all_programs = $query->query($args); return array_map(function ($entry) { return array('#value' => $entry->ID, '#title' => $entry->post_title); }, $all_programs); }
function _get_register_post($salon_id, $name, $mobile, $post_type = POST_TYPE_SALON_REGISTER) { $query = new WP_Query(); $posts = $query->query(array('post_type' => $post_type, 'post_status' => array('public', 'pending'), 'meta_query' => array(array('key' => 'salon_id', 'value' => serialize(array($salon_id))), array('key' => 'name', 'value' => $name), array('key' => 'mobile', 'value' => $mobile)), 'posts_per_page' => 1)); if (count($posts) > 0) { return $posts[0]; } return false; }
private function set_filtered_ids() { global $wp_query; if (isset(self::$filtered_ids)) { return; } $args = array_merge($wp_query->query, array('fields' => 'ids', 'nopaging' => true, 'no_found_rows' => true, 'ignore_sticky_post' => true, 'cache_results' => false)); $query = new WP_Query(); self::$filtered_ids = $query->query($args); }
/** * Returns the latest "metadata" post. There should be only one per book. * * @return \WP_Post|bool */ function getMetaPost() { $args = array('post_type' => 'metadata', 'posts_per_page' => 1, 'post_status' => 'publish', 'orderby' => 'modified', 'no_found_rows' => true, 'cache_results' => true); $q = new \WP_Query(); $results = $q->query($args); if (empty($results)) { return false; } return $results[0]; }