コード例 #1
1
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;
}
コード例 #2
1
function bap_ajaxP_loop($offset = '')
{
    global $wp_query;
    $paged = get_query_var('page') ? get_query_var('page') : 1;
    $do_not_duplicate = array();
    // OFFSET SETTING
    if (!$offset == '' || !$offset == '0') {
        $argshidepost = array('numberposts' => $offset, 'post_type' => 'post', 'post_status' => 'publish');
        $hide_to_array = get_posts($argshidepost);
        // HIDE OFFSETED POSTS
        if ($hide_to_array) {
            foreach ($hide_to_array as $post) {
                $do_not_duplicate[] = $post->ID;
            }
        }
    }
    $argsmain = array('post_type' => 'post', 'post_status' => 'publish', 'paged' => $paged, 'order' => 'DESC', 'post__not_in' => $do_not_duplicate);
    $wp_query = new WP_Query($argsmain);
    if ($wp_query->have_posts()) {
        echo '<section id="' . bap_get_option_text('bap_loopContainer') . '">';
        while ($wp_query->have_posts()) {
            $wp_query->the_post();
            get_template_part('partials/listitem');
        }
        echo '</section>';
    }
    wp_reset_postdata();
}
コード例 #3
1
 public function get_Relationships_by_Tag($tag, $_method, $_route, $_path, $_headers)
 {
     if (empty($tag) || !is_string($tag)) {
         return new WP_Error('json_options_invalid_tag', __("Invalid options tag"), ['status' => 404]);
     }
     $site = $_headers['REMOTE'];
     $tags = explode(',', $tag);
     if ($tags) {
         $tags_query['relation'] = 'OR';
         foreach ($tags as $tag) {
             $tags_query[] = array('key' => 'related_tags', 'value' => $tag, 'compare' => 'LIKE');
         }
     }
     $args = array('post_type' => 'relationship', 'meta_query' => array('relation' => 'AND', array('key' => 'site_address', 'value' => $site), $tags_query));
     $relationships = new WP_Query($args);
     if ($relationships->have_posts()) {
         // Get the Target Categories
         $targets = [];
         while ($relationships->have_posts()) {
             $relationships->the_post();
             $targets[] = get_field('target_category');
         }
         $targets = dedupe($targets);
         $related_categories = implode(', ', $targets);
         // Find Matching Relationships
         $args = array('post_type' => 'relationship', 'tax_query' => array(array('taxonomy' => 'related_categories', 'terms' => $related_categories)));
         $relationships = new WP_Query($args);
         // Build Relationships JSON Reponse
         include 'related-json-response.php';
     }
     wp_reset_query();
     return $sites;
 }
コード例 #4
0
    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;
    }
コード例 #5
0
 function bl_posttype_shortcodes_showposts($params = array())
 {
     // Pulls the paramater values passed from the shortcode options
     extract(shortcode_atts(array('post_type' => 'post', 'post_status' => 'publish', 'offset' => 0, 'posts_per_page' => ''), $params));
     // Builds the query based on the available params
     $query = new WP_Query(array('post_type' => $post_type, 'post_status' => $post_status, 'offset' => $offset, 'posts_per_page' => $posts_per_page));
     // Looks for the presence of any qualifying posts inside the defined loop
     if ($query->have_posts()) {
         // We open the post container only where specified posts are available
         $shortcodeOutput = '<div>';
         while ($query->have_posts()) {
             $query->the_post();
             // Wraps each qualifying post for output in an <article> tag with Schema data.
             $shortcodeOutput .= '<article itemscope itemtype="http://schema.org/Article">';
             $shortcodeOutput .= '<a href="' . get_the_permalink() . '">';
             $shortcodeOutput .= '<h3 itemprop="name">' . get_the_title() . '</h3>';
             $shortcodeOutput .= '</a>';
             $shortcodeOutput .= '<time itemprop="dateCreated">' . get_the_date() . '</time>';
             $shortcodeOutput .= '<em itemprop="author">' . get_the_author() . '</em>';
             $shortcodeOutput .= '<div itemprop="description">' . get_the_excerpt() . '</div>';
             $shortcodeOutput .= '<article>';
         }
         // Closes off the parent container
         $shortcodeOutput .= '</div>';
     }
     // Resets the wordpress loop
     wp_reset_postdata();
     // Returns the concatenated shortcodeOutput to the page
     return $shortcodeOutput;
 }
コード例 #6
0
    function widget($args, $instance)
    {
        global $post;
        // Preserve global $post
        $preserve = $post;
        extract($args);
        // only useful on post pages
        if (!is_single()) {
            return;
        }
        $title = apply_filters('widget_title', empty($instance['title']) ? __('Read Next', 'largo') : $instance['title'], $instance, $this->id_base);
        echo $before_widget;
        if ($title) {
            echo $before_title . $title . $after_title;
        }
        $related = new Largo_Related($instance['qty']);
        //get the related posts
        $rel_posts = new WP_Query(array('post__in' => $related->ids(), 'nopaging' => 1, 'posts_per_page' => $instance['qty'], 'ignore_sticky_posts' => 1));
        if ($rel_posts->have_posts()) {
            echo '<ul class="related">';
            while ($rel_posts->have_posts()) {
                $rel_posts->the_post();
                echo '<li>';
                echo '<a href="' . get_permalink() . '"/>' . get_the_post_thumbnail(get_the_ID(), 'thumbnail', array('class' => 'alignleft')) . '</a>';
                ?>
				<h4><a href="<?php 
                the_permalink();
                ?>
" title="Read: <?php 
                esc_attr(the_title('', '', FALSE));
                ?>
"><?php 
                the_title();
                ?>
</a></h4>
				<h5 class="byline">
					<span class="by-author"><?php 
                largo_byline(true, true);
                ?>
</span>
					<time class="entry-date updated dtstamp pubdate" datetime="<?php 
                echo esc_attr(get_the_date('c'));
                ?>
"><?php 
                largo_time();
                ?>
</time>
				</h5>
				<?php 
                // post excerpt/summary
                largo_excerpt(get_the_ID(), 2, false, '', true);
                echo '</li>';
            }
            echo "</ul>";
        }
        echo $after_widget;
        // Restore global $post
        wp_reset_postdata();
        $post = $preserve;
    }
コード例 #7
0
 /**
  * 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)
 {
     echo $args['before_widget'];
     if (!empty($instance['title'])) {
         echo $args['before_title'] . apply_filters('widget_title', $instance['title']) . $args['after_title'];
     }
     // The Query
     $query_args = array('post_type' => 'post', 'post_per_page' => 5, 'meta_key' => 'views', 'orderby' => 'meta_value_num', 'order' => 'DESC', 'ignore_sticky_posts' => 'true');
     $the_query = new WP_Query($query_args);
     // The Loop
     if ($the_query->have_posts()) {
         echo '<ul>';
         while ($the_query->have_posts()) {
             $the_query->the_post();
             echo '<li>';
             echo '<a href="' . get_the_permalink() . '" rel="bookmark">';
             echo get_the_title();
             echo '(' . get_post_meta(get_the_ID(), 'views', true) . ')';
             echo '</a>';
             echo '</li>';
         }
         echo '</ul>';
     } else {
         // no posts found
     }
     /* Restore original Post Data */
     wp_reset_postdata();
     echo $args['after_widget'];
 }
コード例 #8
0
ファイル: _slider_ktz.php プロジェクト: jjpango/JJTeam
 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">&times;</a>';
             echo '<ul class="mustread_list">';
             while ($ktz_topfeatquery->have_posts()) {
                 $ktz_topfeatquery->the_post();
                 echo '<li class="mustread_li clearfix">';
                 echo '<div class="pull-left">';
                 echo ktz_featured_img(50, 50);
                 echo '</div>';
                 echo '<div class="title">';
                 echo ktz_posted_title_a();
                 echo '</div>';
                 echo '</li>';
             }
             echo '</ul>';
             echo '</div>';
         }
         wp_reset_query();
     }
 }
コード例 #9
0
/**
 * kool_preview_boxes shows the next set of posts. It shows as many boxes as
 * you show posts on your blog page. This works best when there is an even
 * number of posts displayed (2,4,6,8,10) but it can work with an odd number
 * if alignment is set or if the width of boxes is set to 100% which would allow
 * for a column effct.
 * 
 * To use kool_preview simply add the function call in your theme's index after
 * the content is displayed. I could technically go before as well.      
 */
function kool_preview_boxes()
{
    global $post;
    if (is_paged()) {
        $target_page = get_query_var('paged') + 1;
    } else {
        $target_page = 2;
    }
    $args = array('paged' => $target_page, 'orderby' => 'post_date', 'post_type' => 'post', 'post_status' => 'publish');
    $k_posts = new WP_Query($args);
    if ($k_posts and $k_posts->have_posts()) {
        while ($k_posts->have_posts()) {
            $k_posts->the_post();
            $thumb_query = array('numberposts' => 1, 'post_type' => 'attachment', 'post_parent' => $post->ID);
            echo '<div class="preview_box" >';
            $attachment = get_posts($thumb_query);
            foreach ($attachment as $attach) {
                if ($attach) {
                    $img = wp_get_attachment_image_src($attach->ID, $size = 'thumbnail', $icon = true);
                    echo "<img class='preview_thumb' src='{$img['0']}' >";
                }
            }
            echo '<a rel="bookmark" href=';
            the_permalink();
            echo '>';
            echo the_title() . '</a><br>';
            the_excerpt();
            echo "</div>";
        }
    }
}
コード例 #10
0
ファイル: woocalendar.php プロジェクト: NumanAfifi/wp-demo
function td_events_api()
{
    $events = array();
    $start = isset($_GET['start']) ? $_GET['start'] : '';
    $end = isset($_GET['end']) ? $_GET['end'] : '';
    $args = array('post_type' => 'event');
    $query = new WP_Query($args);
    if ($query->have_posts()) {
        while ($query->have_posts()) {
            $query->the_post();
            $parent = get_post(get_post_meta(get_the_ID(), 'tdec_product', true));
            $dates = get_post_meta(get_the_ID(), 'tdec_dates', true);
            $color = get_post_meta(get_the_ID(), 'tdec_color', true);
            if (is_array($dates)) {
                foreach ($dates as $date) {
                    $event = array('title' => $parent->post_title, 'start' => date('c', $date['start']), 'end' => date('c', $date['end']), 'url' => get_permalink($parent->ID), 'backgroundColor' => $color);
                    $events[] = $event;
                }
            }
        }
    }
    wp_reset_postdata();
    echo json_encode($events);
    die;
}
コード例 #11
0
ファイル: logic_.php プロジェクト: eliascantoral/guaflix
function get_sliderobjects_array($slider)
{
    $category = get_field("categoria", $slider);
    $category_list = "";
    $return = array();
    $index = 0;
    for ($i = 0; $i < sizeof($category); $i++) {
        $category_list .= strlen($category_list) > 0 ? "," : "";
        $category_list .= $category[$i];
    }
    $option = get_field("opciones", $slider);
    //print_array($option);
    //print_array($category);
    // WP_Query arguments
    $args = array('post_type' => 'objeto', 'post_status' => 'publish', 'cat' => $category_list, 'order' => 'DESC', 'orderby' => 'date');
    // The Query
    $category_posts = new WP_Query($args);
    if ($category_posts->have_posts()) {
        while ($category_posts->have_posts()) {
            $category_posts->the_post();
            $return[$index] = get_the_ID();
            $index++;
        }
    }
    return $return;
}
コード例 #12
0
function tpp_posts_widget()
{
    $tpp_posts_query = new WP_Query();
    $tpp_posts_query->get_posts();
    ?>
	<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();
            ?>
)
	<?php 
        }
    }
    ?>
	<?php 
}
コード例 #13
0
 /**
  * widget function.
  *
  * @see WP_Widget
  * @access public
  * @param array $args
  * @param array $instance
  * @return void
  */
 public function widget($args, $instance)
 {
     if ($this->get_cached_widget($args)) {
         return;
     }
     ob_start();
     extract($args);
     $title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base);
     $number = absint($instance['number']);
     add_filter('posts_clauses', array(WC()->query, 'order_by_rating_post_clauses'));
     $query_args = array('posts_per_page' => $number, 'no_found_rows' => 1, 'post_status' => 'publish', 'post_type' => 'product');
     $query_args['meta_query'] = WC()->query->get_meta_query();
     $r = new WP_Query($query_args);
     if ($r->have_posts()) {
         echo $before_widget;
         if ($title) {
             echo $before_title . $title . $after_title;
         }
         echo '<ul class="product_list_widget">';
         while ($r->have_posts()) {
             $r->the_post();
             wc_get_template('content-widget-product.php', array('show_rating' => true));
         }
         echo '</ul>';
         echo $after_widget;
     }
     remove_filter('posts_clauses', array(WC()->query, 'order_by_rating_post_clauses'));
     wp_reset_postdata();
     $content = ob_get_clean();
     echo $content;
     $this->cache_widget($args, $content);
 }
コード例 #14
0
/**
	*边栏文章列表
	*http://www.bgbk.org
*/
function Bing_sidebar_posts_list($query_args, $thumbnail = true)
{
    $query = new WP_Query($query_args);
    if ($query->have_posts()) {
        echo '<ul class="sidebar-posts-list">';
        while ($query->have_posts()) {
            $query->the_post();
            Bing_sidebar_posts_list_loop($thumbnail);
        }
        wp_reset_postdata();
        echo '</ul>';
    } else {
        ?>
		<div class="empty-sidebar-posts-list">
			<p><?php 
        _e('这里什么都没有,你也许可以使用搜索功能找到你需要的内容:');
        ?>
</p>
			<?php 
        get_search_form();
        ?>
		</div>
<?php 
    }
}
コード例 #15
0
ファイル: shortcodes.php プロジェクト: futr3/cdt-fsf
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);
}
コード例 #16
0
ファイル: archives.php プロジェクト: katstar01/fivebeers
/**
 * Ajax function for loading posts by date and category
 */
function wp_ajax_load_posts()
{
    if (!wp_verify_nonce($_GET['_wpnonce'], 'nonce-ajax-dropdown')) {
        die('Go away!');
    }
    $year = isset($_GET['year']) ? $_GET['year'] : '';
    $month = isset($_GET['month']) ? $_GET['month'] : '';
    $args = array('year' => trim($year), 'monthnum' => trim($month), 'posts_per_page' => -1, 'orderby' => 'date', 'cat' => trim($_GET['cat'] != "-1") ? trim($_GET['cat']) : 0);
    $ajaxsort = new WP_Query($args);
    ?>
	    <?php 
    if ($ajaxsort->have_posts()) {
        ?>
	</div>
		<?php 
        while ($ajaxsort->have_posts()) {
            $ajaxsort->the_post();
            ?>
			<?php 
            get_template_part('content', 'archives');
            ?>
	    <?php 
        }
        ?>

		<?php 
    } else {
        echo '<div align="center">Nothing Found!</div></nav>';
    }
    exit;
}
コード例 #17
0
function rec_epl_lu_single_download()
{
    global $post, $epl_settings;
    $unique_id = get_post_meta($post->ID, 'property_unique_id', true);
    $tab_title = isset($epl_settings['epl_lu_group_title']) ? __($epl_settings['epl_lu_group_title'], 'epl') : __('Extra Info', 'epl');
    $query = new WP_Query(array('post_type' => 'listing_unlimited', 'meta_query' => array(array('key' => 'property_unique_id', 'value' => $unique_id, 'compare' => '=='))));
    if ($query->have_posts()) {
        while ($query->have_posts()) {
            $query->the_post();
            $link = get_post_meta($post->ID, 'listing_unlimited_pdf', true);
            ?>

			<div style="xxxdisplay:none" class="rec-panel-section-32 xxxfancybox-hidden">
				<div id="xxxfancyboxID-section-32">
					<?php 
            echo do_shortcode('[gravityform id="21" title="false" description="false" tabindex="33"]');
            ?>
				</div>
			</div>
			<!--<h5 class="widget-sub-title download"><a href="#fancyboxID-section-32" class="rec-panel-section-32-popout-fancybox fancybox"><i class="fa fa-file-pdf-o"></i> Download Section 32</a></h5>-->

			<?php 
        }
    }
    wp_reset_postdata();
}
コード例 #18
0
 function ot_type_portfolio_select($args = array())
 {
     /* turns arguments array into variables */
     extract($args);
     /* verify a description */
     $has_desc = $field_desc ? true : false;
     /* format setting outer wrapper */
     echo '<div class="format-setting type-page-select ' . ($has_desc ? 'has-desc' : 'no-desc') . '">';
     /* description */
     echo $has_desc ? '<div class="description">' . htmlspecialchars_decode($field_desc) . '</div>' : '';
     /* format setting inner wrapper */
     echo '<div class="format-setting-inner">';
     /* build page select */
     echo '<select name="' . esc_attr($field_name) . '" id="' . esc_attr($field_id) . '" class="option-tree-ui-select ' . $field_class . '">';
     /* query pages array */
     $query = new WP_Query(array('meta_query' => array(array('key' => '_wp_page_template', 'value' => array('template-portfolio.php', 'template-portfolio-shapes.php', 'template-portfolio-paginated.php'), 'compare' => 'IN')), 'post_type' => array('page'), 'posts_per_page' => -1, 'orderby' => 'title', 'order' => 'ASC', 'post_status' => 'any'));
     /* has pages */
     if ($query->have_posts()) {
         echo '<option value="">-- ' . __('Choose One', 'option-tree') . ' --</option>';
         while ($query->have_posts()) {
             $query->the_post();
             echo '<option value="' . esc_attr(get_the_ID()) . '"' . selected($field_value, get_the_ID(), false) . '>' . esc_attr(get_the_title()) . '</option>';
         }
     } else {
         echo '<option value="">' . __('No Pages Found', 'option-tree') . '</option>';
     }
     echo '</select>';
     echo '</div>';
     echo '</div>';
 }
コード例 #19
0
function load_more_posts_callback()
{
    check_ajax_referer('pan_travel_blog', 'token');
    try {
        $offset = $_POST['offset'];
        $number = $_POST['number'];
        $loop = new WP_Query(array('post_type' => 'travel_blogs', 'post_status' => 'publish', 'order' => 'DESC', 'orderby' => 'meta_value', 'meta_key' => 'travel_blog_start_date', 'offset' => $offset, 'posts_per_page' => $number));
        if ($loop->have_posts()) {
            while ($loop->have_posts()) {
                $loop->the_post();
                ?>
				<?php 
                get_template_part('parts/content', 'travelblog');
                ?>
			<?php 
            }
        } else {
            ?>
			<p><?php 
            _e('Sorry, no posts matched your criteria.');
            ?>
</p>
		<?php 
        }
        wp_reset_postdata();
    } catch (Exception $e) {
        echo 'Errors';
    }
    wp_die();
}
コード例 #20
0
 /**
  * widget function.
  *
  * @see WP_Widget
  * @access public
  * @param array $args
  * @param array $instance
  * @return void
  */
 public function widget($args, $instance)
 {
     global $comments, $comment, $woocommerce;
     if ($this->get_cached_widget($args)) {
         return;
     }
     ob_start();
     extract($args);
     $title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base);
     $number = absint($instance['number']);
     $query_args = array('posts_per_page' => $number, 'no_found_rows' => 1, 'post_status' => 'publish', 'post_type' => 'product', 'post__in' => $viewed_products, 'orderby' => 'rand');
     $query_args['meta_query'] = array();
     $query_args['meta_query'][] = WC()->query->stock_status_meta_query();
     $query_args['meta_query'] = array_filter($query_args['meta_query']);
     $r = new WP_Query($query_args);
     if ($r->have_posts()) {
         echo $before_widget;
         if ($title) {
             echo $before_title . $title . $after_title;
         }
         echo '<ul class="product_list_widget">';
         while ($r->have_posts()) {
             $r->the_post();
             wc_get_template('content-widget-product.php');
         }
         echo '</ul>';
         echo $after_widget;
     }
     wp_reset_postdata();
     $content = ob_get_clean();
     echo $content;
 }
コード例 #21
0
 /**
  * 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)
 {
     echo $args['before_widget'];
     $display_title = !empty($instance['display_title']) ? $instance['display_title'] : '';
     $numberofposts = !empty($instance['numberofposts']) ? absint($instance['numberofposts']) : '';
     if ($display_title == 'on') {
         if (!empty($instance['title'])) {
             echo $args['before_title'] . apply_filters('widget_title', $instance['title']) . $args['after_title'];
         }
     }
     $post_query_args = array('post_type' => array('post'), 'pagination' => false, 'posts_per_page' => $numberofposts, 'ignore_sticky_posts' => true, 'cache_results' => true, 'update_post_meta_cache' => true, 'update_post_term_cache' => true);
     $post_query = new WP_Query($post_query_args);
     if ($post_query->have_posts()) {
         while ($post_query->have_posts()) {
             $post_query->the_post();
             global $post;
             $output = '';
             $output .= '<div class="widget-recent-post clearfix">';
             $output .= has_post_thumbnail($post->ID) ? '<div class="recent-post-image">' : '';
             $output .= has_post_thumbnail($post->ID) ? get_the_post_thumbnail($post->ID, 'illdy-widget-recent-posts') : '';
             $output .= has_post_thumbnail($post->ID) ? '</div><!--/.recent-post-image-->' : '';
             $output .= '<a href="' . esc_url(get_the_permalink()) . '" title="' . esc_attr(get_the_title()) . '" class="recent-post-title">' . esc_html(get_the_title()) . '</a>';
             $output .= '<a href="' . esc_url(get_the_permalink()) . '" title="' . __('More...', 'illdy') . '" class="recent-post-button">' . __('More...', 'illdy') . '</a>';
             $output .= '</div><!--/.widget-recent-post.clearfix-->';
             echo $output;
         }
     } else {
         echo __('No posts found.', 'illdy');
     }
     wp_reset_postdata();
     echo $args['after_widget'];
 }
コード例 #22
0
ファイル: functions.php プロジェクト: bsfignoni/revistafilm
function mostrarRevistas()
{
    // WP_Query arguments
    $args = array('post_type' => array('revistas'), 'order' => 'DESC');
    // The Query
    $revistas = new WP_Query($args);
    if ($revistas->have_posts()) {
        $outputs = '<div class="grids entries revistas">';
        while ($revistas->have_posts()) {
            $revistas->the_post();
            $thumb_id = get_post_thumbnail_id();
            $thumb_url = wp_get_attachment_image_src($thumb_id, 'big', true);
            $url = $thumb_url[0];
            $outputs .= '<article class="grid-3 post type-post format-standard has-post-thumbnail hentry">';
            $outputs .= '<figure class="entry-image inview">';
            $outputs .= '<a href="' . get_the_permalink() . '">';
            $outputs .= '<img src="' . $url . '" class="attachment-rectangle-size wp-post-image" alt="' . get_the_title() . '">';
            $outputs .= '</a>';
            $outputs .= '</figure>';
            $outputs .= '<header class="entry-header">';
            $outputs .= '<h2 class="entry-title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>';
            $outputs .= '</header>';
            $outputs .= '</article>';
        }
        $outputs .= '</div>';
    }
    wp_reset_query();
    // Restore global post data stomped by the_post().
    return $outputs;
}
コード例 #23
0
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;
}
コード例 #24
0
ファイル: mega-menu.php プロジェクト: aromis/dw-focus
 function end_el(&$output, $item, $depth = 0, $args = array())
 {
     if ($depth == 0 && $item->object == 'category') {
         $output .= "<div class='subcat'>";
         for ($i = 0; $i < count($item->children); $i++) {
             $child = $item->children[$i];
             $output .= "<div class='" . ($i === 0 ? 'active' : '') . "' id='mn-latest-" . $child->ID . "'>";
             //$output .="<h5>".$child->title."</h5>";
             $output .= "<ul id='mn-latest-" . $child->ID . "'>";
             if ($child->object == 'category') {
                 $r = new WP_Query(apply_filters('widget_posts_args', array('posts_per_page' => 5, 'no_found_rows' => true, 'post_status' => 'publish', 'cat' => $child->object_id)));
                 if ($r->have_posts()) {
                     while ($r->have_posts()) {
                         $r->the_post();
                         $output .= "<li ";
                         if (has_post_thumbnail()) {
                             $output .= "class='has-thumbnail' ";
                         }
                         $output .= "><div class='subcat-thumbnail'><a href='" . get_permalink() . "' title='" . get_the_title() . "'>" . get_the_post_thumbnail(get_the_ID(), array(40, 40)) . "</a></div><div class='subcat-title'><a href='" . get_permalink() . "' title='" . get_the_title() . "'> " . get_the_title() . "</a><span> - " . dw_human_time_diff(get_the_time('U'), current_time('timestamp')) . "</span></div></li>";
                     }
                     // Reset the global $the_post as this query will have stomped on it
                     wp_reset_postdata();
                 }
             }
             $output .= "</ul>";
             $output .= "<a href='" . $child->url . "' title='" . $child->attr_title . "'>View all</a>";
             $output .= "</div>";
         }
         $output .= "</div> \n</div>\n";
     } else {
     }
     $output .= "</li>\n";
 }
コード例 #25
0
    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;
    }
コード例 #26
0
 /**
  * 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();
 }
コード例 #27
0
ファイル: functions.php プロジェクト: 8ozStudios/code-samples
function echo_state_results()
{
    $args = array('post_type' => 'property', 'posts_per_page' => '99999');
    $query = new WP_Query($args);
    $stateCount = array();
    if ($query->have_posts()) {
        while ($query->have_posts()) {
            $query->the_post();
            if (get_post_meta($query->post->ID, 'state', true)) {
                $cur = 0;
                if ($stateCount[get_post_meta($query->post->ID, 'state', true)]) {
                    $cur = $stateCount[get_post_meta($query->post->ID, 'state', true)];
                }
                $stateCount[get_post_meta($query->post->ID, 'state', true)] = $cur + 1;
            }
            //echo '(' . get_post_meta( $query->post->ID, 'state', true ). ') ';
        }
    }
    echo '<script type="text/javascript">';
    //echo 'var stateCount = []; stateCount["Arizona"]=0; stateCount["Colorado"]=0; stateCount["Delaware"]=0; stateCount["Florida"]=0; stateCount["Georgia"]=0; stateCount["Hawaii"]=0; stateCount["Idaho"]=0; stateCount["Illinois"]=0; stateCount["Indiana"]=0; stateCount["Iowa"]=0; stateCount["Kansas"]=0; stateCount["Kentucky"]=0; stateCount["Louisiana"]=0; stateCount["Maryland"]=0; stateCount["Maine"]=0; stateCount["Massachusetts"]=0; stateCount["Minnesota"]=0; stateCount["Michigan"]=0; stateCount["Mississippi"]=0; stateCount["Missouri"]=0; stateCount["Montana"]=0; stateCount["NorthCarolina"]=0; stateCount["Nebraska"]=0; stateCount["Nevada"]=0; stateCount["NewHampshire"]=0; stateCount["NewJersey"]=0; stateCount["NewYork"]=0; stateCount["NorthDakota"]=0; stateCount["NewMexico"]=0; stateCount["Ohio"]=0; stateCount["Oklahoma"]=0; stateCount["Oregon"]=0; stateCount["Pennsylvania"]=0; stateCount["RhodeIsland"]=0; stateCount["SouthCarolina"]=0; stateCount["SouthDakota"]=0; stateCount["Tennessee"]=0; stateCount["Texas"]=0; stateCount["Utah"]=0; stateCount["Wisconsin"]=0; stateCount["Virginia"]=0; stateCount["Vermont"]=0; stateCount["Washington"]=0; stateCount["WestVirginia"]=0; stateCount["Wyoming"]=0; stateCount["California"]=0; stateCount["Connecticut"]=0; stateCount["Alaska"]=0; stateCount["Arkansas"]=0; stateCount["Alabama"]=0;';
    echo 'var stateCount = [];';
    foreach ($stateCount as $key => $value) {
        echo 'stateCount["' . str_replace(' ', '', $key) . '"] = "' . $value . '";';
    }
    echo '</script>';
}
 /**
  * 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
  **/
 public function widget($args, $instance)
 {
     extract($args, EXTR_SKIP);
     $count = esc_attr($instance['count']);
     $count = 0 < $count && $count < 10 ? $count : 2;
     $loop = new WP_Query(array('post_type' => 'event', 'posts_per_page' => $count, 'order' => 'ASC', 'orderby' => 'meta_value_num', 'meta_key' => '_event_start', 'meta_query' => array(array('key' => '_event_end', 'value' => time(), 'compare' => '>'))));
     if ($loop->have_posts()) {
         echo $before_widget;
         if ($instance['title']) {
             echo $before_title . apply_filters('widget_title', $instance['title']) . $after_title;
         }
         echo '<ul>';
         while ($loop->have_posts()) {
             $loop->the_post();
             global $post;
             $output = '<span class="meta">' . date(get_option('date_format'), get_post_meta(get_the_ID(), '_event_start', true)) . '</span> <a href="' . get_permalink() . '">' . get_the_title() . '</a>';
             $read_more = apply_filters('em4wp_events_manager_upcoming_widget_output', $output, $post);
             if ($read_more) {
                 echo '<li>' . $read_more . '</li>';
             }
         }
         if ($instance['more_text']) {
             echo '<li><a href="' . get_post_type_archive_link('event') . '">' . esc_attr($instance['more_text']) . '</a></li>';
         }
         echo '</ul>';
         echo $after_widget;
     }
     wp_reset_postdata();
 }
コード例 #29
0
function show_faq($atts)
{
    ob_start();
    $secondary_query = new WP_Query(array('post_type' => 'questions', 'posts_per_page' => $atts[limit], 'tax_query' => array(array('taxonomy' => 'faq', 'field' => 'slug', 'terms' => $atts[category], 'operator' => 'IN'))));
    if ($secondary_query->have_posts()) {
        while ($secondary_query->have_posts()) {
            $secondary_query->the_post();
            echo '
								<div class="row">
									<div class="col-lg-8 col-lg-offset-2 centered">
							';
            the_post();
            the_post_thumbnail('thumbnail');
            the_title('<h1>', '</h1>');
            the_content();
            echo '
									</div>
								</div>
							';
        }
        // end while
    }
    // end if
    wp_reset_postdata();
    return ob_get_clean();
}
コード例 #30
-1
 /**
  * Output widget.
  *
  * @see WP_Widget
  *
  * @param array $args
  * @param array $instance
  */
 public function widget($args, $instance)
 {
     $viewed_products = !empty($_COOKIE['woocommerce_recently_viewed']) ? (array) explode('|', $_COOKIE['woocommerce_recently_viewed']) : array();
     $viewed_products = array_reverse(array_filter(array_map('absint', $viewed_products)));
     if (empty($viewed_products)) {
         return;
     }
     ob_start();
     $number = !empty($instance['number']) ? absint($instance['number']) : $this->settings['number']['std'];
     $query_args = array('posts_per_page' => $number, 'no_found_rows' => 1, 'post_status' => 'publish', 'post_type' => 'product', 'post__in' => $viewed_products, 'orderby' => 'post__in');
     $query_args['meta_query'] = array();
     $query_args['meta_query'][] = WC()->query->stock_status_meta_query();
     $query_args['meta_query'] = array_filter($query_args['meta_query']);
     $r = new WP_Query($query_args);
     if ($r->have_posts()) {
         $this->widget_start($args, $instance);
         echo apply_filters('woocommerce_before_widget_product_list', '<ul class="product_list_widget">');
         while ($r->have_posts()) {
             $r->the_post();
             wc_get_template('content-widget-product.php');
         }
         echo apply_filters('woocommerce_after_widget_product_list', '</ul>');
         $this->widget_end($args);
     }
     wp_reset_postdata();
     $content = ob_get_clean();
     echo $content;
 }