Esempio n. 1
6
function charity_vc_our_mission($atts, $content = null)
{
    extract(shortcode_atts(array('our_mission' => ''), $atts));
    $page_id = get_page_by_title($our_mission);
    $missionQuery = new WP_Query(array("page_id" => $page_id->ID));
    if ($missionQuery->have_posts()) {
        $missionQuery->the_post();
        $url = wp_get_attachment_image_src(get_post_thumbnail_id($page_id->ID), array(1143, 479));
        ?>
        <!-- Save Lives Section Start Here-->
        <section class="save-lives text-center parallax" style="background-image: url('<?php 
        echo esc_url($url[0]);
        ?>
')">
            <div class="container">
                <div class="row">
                    <div class="col-xs-12 col-sm-8 col-sm-offset-2 col-md-6 col-md-offset-3">
                        <header class="page-header">
                            <h2><?php 
        the_title();
        ?>
</h2>
                            <?php 
        the_content();
        ?>
                        </header>
                    </div>
                </div>
            </div>
        </section>
        <!-- Save Lives Section Start Here-->
    <?php 
    }
    wp_reset_postdata();
}
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();
}
Esempio n. 3
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;
}
 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;
 }
 /**
  * Blockquote shortcode callback
  *
  * @param  array  $atts    shortcode attributes
  * @param  string $content shortcode content
  * @param  string $code    shortcode name
  * @return string          output html
  */
 public static function dispatch($atts, $content, $code)
 {
     extract(shortcode_atts(array('layout' => 'slider', 'cat' => '', 'ids' => '', 'autorotate' => false), $atts));
     $query = array('post_type' => 'testimonials', 'orderby' => 'menu_order', 'order' => 'DESC', 'posts_per_page' => -1);
     if (!empty($cat)) {
         $query['tax_query'] = array(array('taxonomy' => 'testimonials_category', 'field' => 'slug', 'terms' => explode(',', $cat)));
     }
     if ($ids && $ids != 'null') {
         $query['post__in'] = explode(',', $ids);
     }
     $q = new WP_Query($query);
     $output = '';
     if ($layout == 'slider') {
         $slides = array();
         while ($q->have_posts()) {
             $q->the_post();
             $slides[] = array('type' => 'html', 'html' => self::format());
         }
         $output = wpv_shortcode_slider(array('pager' => true, 'controls' => false, 'auto' => wpv_sanitize_bool($autorotate)), json_encode($slides), 'slider');
     } else {
         $output .= '<div class="blockquote-list">';
         while ($q->have_posts()) {
             $q->the_post();
             $output .= self::format();
         }
         $output .= '</div>';
     }
     wp_reset_postdata();
     return $output;
 }
 function widget($args, $instance)
 {
     extract($args);
     $instance = wp_parse_args($instance, $this->default);
     if (function_exists('icl_t')) {
         $instance['supertitle'] = icl_t('PRESSO Widget', $this->id . '_supertitle', $instance['supertitle']);
         $instance['title'] = icl_t('PRESSO Widget', $this->id . '_title', $instance['title']);
         $instance['subtitle'] = icl_t('PRESSO Widget', $this->id . '_subtitle', $instance['subtitle']);
     }
     $supertitle_html = '';
     if (!empty($instance['supertitle'])) {
         $supertitle_html = sprintf(__('<span class="super-title">%s</span>', 'envirra'), $instance['supertitle']);
     }
     $title_html = '';
     if (!empty($instance['title'])) {
         $title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base);
         $title_html = $supertitle_html . $title;
     }
     $subtitle_html = '';
     if (!empty($instance['subtitle'])) {
         $subtitle_html = sprintf(__('<p class="section-description">%s</p>', 'envirra'), $instance['subtitle']);
     }
     $category = intval($instance['category']);
     $thumbnail = $instance['thumbnail'];
     $format = $instance['format'];
     $count = intval($instance['count']);
     echo $before_widget;
     if ($instance['title']) {
         echo $before_title . $title_html . $after_title . $subtitle_html;
     }
     global $post;
     $args = array('post_type' => 'post', 'orderby' => 'post_date', 'ignore_sticky_posts' => true, 'posts_per_page' => $count);
     if ($category > 0) {
         $args['cat'] = $category;
     }
     if (!empty($format)) {
         $args['tax_query'] = array(array('taxonomy' => 'post_format', 'field' => 'slug', 'terms' => array('post-format-' . $format)));
     }
     $the_query = new WP_Query($args);
     echo '<div class="post-box-list">';
     if ('large' == $thumbnail || 'small' == $thumbnail) {
         while ($the_query->have_posts()) {
             $the_query->the_post();
             get_template_part('templates/post-box/' . $thumbnail . '-thumbnail', get_post_format());
         }
     } else {
         if ($the_query->have_posts()) {
             $the_query->the_post();
             get_template_part('templates/post-box/large-thumbnail', get_post_format());
         }
         while ($the_query->have_posts()) {
             $the_query->the_post();
             get_template_part('templates/post-box/small-thumbnail', get_post_format());
         }
     }
     echo '</div>';
     wp_reset_postdata();
     echo $after_widget;
 }
Esempio n. 7
0
function gm_faq_shortcode( $atts ) {
	extract( shortcode_atts( array(
		'orderby' => 'menu_order',
		'cat' => '',
		'display' => 'excerpt',
	), $atts ) );

	$db_args = array(
		'post_type' => 'faqs',
		'order' => 'ASC',
		'orderby' => $orderby,
		'faq_categories' => $cat,
	);

	$original_query = $wp_query;
	$faqs_loop = new WP_Query( $db_args );
	if($faqs_loop->have_posts()) {
		switch($display) {		
			case "content":
				$content .= "<div class=\"faqs_wrapper\">";
				while( $faqs_loop->have_posts() ) : $faqs_loop->the_post();
					$content_filtered = get_the_content();
					$content_filtered = apply_filters('the_content', $content_filtered);
					$content_filtered = str_replace(']]>', ']]&gt;', $content_filtered);
					$content .= "<div class=\"faq_single\">";
					$content .= "<h3 class=\"faq_title\">".get_the_title()."</h3>";
					$content .= "<div class=\"faq_content\">$content_filtered</div>";
					$content .= "</div>";
				endwhile;
				$content .= "</div>";
				break;
			case "excerpt":
				$content .= "<div class=\"faqs_wrapper\">";
				while( $faqs_loop->have_posts() ) : $faqs_loop->the_post();
					$content .= "<div class=\"faq_single\">";
					$content .= "<h3 class=\"faq_title\"><a href=".get_permalink().">".get_the_title()."</a></h3>";
					$content .= "<div><span class=\"faq_excerpt\">".get_the_excerpt()."</span></div>";
					$content .= "</div>";
				endwhile;
				$content .= "</div>";
				break;
			case "list":
				$content .= "<ul class=\"faqs_wrapper\">";
				while( $faqs_loop->have_posts() ) : $faqs_loop->the_post();
					$content .= "<li class=\"faq_single\">";
					$content .= "<span class=\"faq_title\"><a href=".get_permalink().">".get_the_title()."</a></span>";
					$content .= "</li>";
				endwhile;
				$content .= "</ul>";
				break;
		}
			
	}
	$wp_query = null;
	$wp_query = $original_query;
	wp_reset_postdata();
	return $content;
				
}
 function widget($args, $instance)
 {
     extract($args);
     $title = apply_filters('widget_title', $instance['title']);
     $items = intval($instance['items']);
     $hide = $instance['hide'];
     wp_register_script('needtoknow', plugins_url("/ht-need-to-know/ht_need_to_know.js"));
     wp_enqueue_script('needtoknow');
     //display need to know stories
     $cquery = array('orderby' => 'post_date', 'order' => 'DESC', 'post_type' => 'news', 'posts_per_page' => -1, 'tax_query' => array(array('taxonomy' => 'post_format', 'field' => 'slug', 'terms' => array('post-format-status'))));
     $news = new WP_Query($cquery);
     $read = 0;
     $show = 0;
     $alreadydone = array();
     if ($hide) {
         while ($news->have_posts()) {
             $news->the_post();
             if (isset($_COOKIE['ht_need_to_know_' . get_the_id()])) {
                 $read++;
                 $alreadydone[] = get_the_id();
             } else {
                 $show++;
             }
         }
     } else {
         $show = 1;
     }
     if ($news->post_count != 0 && $news->post_count != $read && $show) {
         echo $before_widget;
         if ($title) {
             echo $before_title . $title . $after_title;
         }
         echo "<div id='need-to-know'><ul class='need'>";
     }
     $k = 0;
     while ($news->have_posts()) {
         $news->the_post();
         if (in_array(get_the_id(), $alreadydone) || $k > $items) {
             continue;
         }
         //don't show if already read
         $k++;
         if ($k > $items) {
             break;
         }
         $thistitle = get_the_title();
         $thisURL = get_permalink();
         $icon = get_option('options_need_to_know_icon');
         if ($icon == '') {
             $icon = "flag";
         }
         echo "<li><a href='{$thisURL}' onclick='Javascript:pauseNeedToKnow(\"ht_need_to_know_" . get_the_id() . "\");'><span class='glyphicon glyphicon-" . $icon . "'></span> " . $thistitle . "</a></li>";
     }
     if ($news->post_count != 0 && $news->post_count != $read && $show) {
         echo "</ul></div>";
         echo $after_widget;
     }
     wp_reset_query();
 }
 public function current()
 {
     global $post;
     $this->_query->the_post();
     // Sets up the global post, but also return the post, for use in Twig template
     $posts_class = $this->_posts_class;
     return new $posts_class($post);
 }
Esempio n. 10
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)
    {
        extract($args);
        $title = apply_filters('widget_title', $instance['title']);
        echo str_replace('class="', 'class="icon-clock ', $before_widget);
        $post_type = $instance['post_type'];
        $postcount = $instance['postcount'];
        $buttontext = $instance['buttontext'];
        $buttonurl = $instance['buttonurl'];
        $show_images = (bool) $instance['show_images'];
        if (!empty($title)) {
            echo $before_title . $title . $after_title;
        }
        $wpbp = new WP_Query(array('post_type' => $post_type, 'posts_per_page' => $postcount, 'post_status' => 'publish'));
        if ($wpbp->have_posts()) {
            if ($show_images === true) {
                // IMAGE TILES
                echo '<ul class="recent-projects-widget">';
                while ($wpbp->have_posts()) {
                    $wpbp->the_post();
                    if (function_exists('has_post_thumbnail') && has_post_thumbnail()) {
                        echo '<li><a href="' . get_permalink() . '">';
                        the_post_thumbnail('thumbnail');
                        echo '</a></li>';
                    }
                }
                echo '</ul>';
            } else {
                // POSTS LINKS
                echo '<ul>';
                while ($wpbp->have_posts()) {
                    $wpbp->the_post();
                    echo '<li><a href="' . get_permalink() . '">';
                    the_title();
                    echo '</a></li>';
                }
                echo '</ul>';
            }
        } else {
            echo '<p>' . __('No recent posts available', 'ishyoboy') . '</p>';
        }
        wp_reset_query();
        if (!empty($buttontext)) {
            ?>
            <a class="btn-small" href="<?php 
            echo esc_attr(apply_filters('ishyoboy_widget_button_url', $buttonurl));
            ?>
"><?php 
            echo $buttontext;
            ?>
</a>
        <?php 
        }
        ?>

        <?php 
        echo $after_widget;
    }
 public function handleShortcode($atts)
 {
     $attributes = shortcode_atts(array('type' => 'floorplans', 'status' => 'publish', 'taxterms' => null, 'taxonomy' => 'property_relationship'), $atts);
     $args = ['post_type' => $attributes['type'], 'posts_per_page' => -1];
     if (isset($attributes['taxterms'])) {
         $args[$attributes['taxonomy']] = $attributes['taxterms'];
     }
     $args['post_status'] = $attributes['status'];
     $floorplans = new WP_Query($args);
     $html = '';
     $count = 0;
     if ($floorplans->have_posts()) {
         $tmp = '';
         $output = '<div class="floorplanFilters">';
         while ($floorplans->have_posts()) {
             $floorplans->the_post();
             $category_classes = '';
             $categories = get_the_terms($floorplans->post->ID, $attributes['taxonomy']);
             if ($categories) {
                 if ($categories[0]->name !== $tmp || $tmp == '') {
                     $filterLinkName = str_replace('-', ' ', str_replace('.', '', $categories[0]->name));
                     $filter = str_replace('.', '', $categories[0]->name);
                     $html .= "<a href='javascript:void()' class='filter button' data-filter=' " . $filter . " '>" . ucwords(htmlentities($filterLinkName)) . "</a>";
                     $count++;
                     ob_start();
                     echo $html;
                     $output .= ob_get_contents();
                     ob_end_clean();
                 }
                 $tmp = $categories[0]->name;
             }
         }
         $output .= "</div>";
         if ($count == 1) {
             $html = "";
         }
         wp_reset_postdata();
         $html .= "<div id='floorplanContainer'>";
         while ($floorplans->have_posts()) {
             $floorplans->the_post();
             $taxTerms = get_the_terms($floorplans->post->ID, $attributes['taxonomy']);
             $floorplan = get_post_meta($floorplans->post->ID);
             $permalink = get_the_permalink();
             $thumb = wp_get_attachment_image_src(get_post_thumbnail_id($floorplans->post->ID), 'thumbnail');
             $imgsrc = $thumb['0'];
             $imgsrc = isset($imgsrc) ? '<img src="' . $imgsrc . '" alt=""/>' : '<img src="http://placehold.it/150x150" alt=""/>';
             $termName = isset($taxTerms[0]) ? $taxTerms[0]->name : '';
             $html .= "<div class='mix '" . str_replace('.', '', $termName) . "'>";
             $html .= "<div class='mix-img'>" . $imgsrc . "</div>";
             $html .= "<h4><a href='" . $permalink . "'> " . $floorplan['fpName'][0] . "</a></h4>";
             $html .= "<p>Starting at \$" . $floorplan['fpMaxRent'][0] . " </p></div>";
         }
         $html .= "</div>";
     }
     wp_reset_postdata();
     return $output . $html;
 }
Esempio n. 12
0
 /**
  * (PHP 5 &gt;= 5.0.0)<br/>
  * Checks if current position is valid
  * @link http://php.net/manual/en/iterator.valid.php
  * @return boolean The return value will be casted to boolean and then evaluated.
  *       Returns true on success or false on failure.
  */
 public function valid()
 {
     if ($this->_query->have_posts()) {
         if (!$this->_query->in_the_loop) {
             $this->_query->the_post();
         }
         return true;
     }
     $this->_query->rewind_posts();
     wp_reset_postdata();
     return false;
 }
function dynamic_shortcode($atts)
{
    ob_start();
    $query = new WP_Query(array('post_type' => 'post', 'order' => 'ASC', 'posts_per_page' => -1));
    if ($query->have_posts()) {
        ?>
<div id="tabs">
<ul class="tab-nav">
  <?php 
        while ($query->have_posts()) {
            $query->the_post();
            ?>
<li><a href="#post-<?php 
            echo get_the_ID();
            ?>
"><?php 
            the_title();
            ?>
</a></li>
  <?php 
        }
        ?>
 </ul>
<?php 
    }
    if ($query->have_posts()) {
        ?>
  <?php 
        while ($query->have_posts()) {
            $query->the_post();
            ?>
  <div id="post-<?php 
            echo get_the_ID();
            ?>
">
    <div class="the-content">
      <?php 
            the_content();
            ?>
    </div>

  </div>
  <?php 
        }
        wp_reset_query();
        ?>
</div>
<?php 
        $myvariable = ob_get_clean();
        return $myvariable;
    }
}
Esempio n. 14
0
function mt_projects_shortcode($atts)
{
    // Attributes
    extract(shortcode_atts(array('number' => '-1', 'category' => '', 'columns' => '3', 'style' => 'hover'), $atts));
    $output = '';
    $scprojects = new WP_Query(array('post_type' => 'project', 'posts_per_page' => $number, 'category_name' => $category));
    if ($scprojects->have_posts()) {
        if ($style == 'hover') {
            $output .= '<section id="mt-projects"><div class="grid grid-pad">';
            while ($scprojects->have_posts()) {
                $scprojects->the_post();
                $output .= '<div class="col-1-' . $columns . ' mt-column-clear"><div class="project-box">';
                $output .= '<a href="' . get_the_permalink() . '">';
                $output .= '<div class="project-content"><div><span>';
                $output .= '<h3>' . get_the_title() . '</h3>';
                $image = wp_get_attachment_image_src(get_post_thumbnail_id(), 'project-thumb');
                $image = $image[0];
                $output .= '<div class="project-bg" style="background-image: url(' . $image . ');"></div>';
                $output .= '</span></div></div>';
                $output .= '</a>';
                $output .= '</div></div>';
            }
            $output .= '</div></section>';
        }
        if ($style == 'image') {
            $output .= '<section id="mt-projects"><div class="grid grid-pad">';
            while ($scprojects->have_posts()) {
                $scprojects->the_post();
                $image = wp_get_attachment_image_src(get_post_thumbnail_id(), 'max-control');
                $image = $image[0];
                $output .= '<a href="' . get_the_permalink() . '">';
                if (has_post_thumbnail(get_the_ID())) {
                    $output .= '<div class="home-project-image-bg" style="background-image: url(' . $image . ');">';
                } else {
                    $output .= '<div class="home-project-image-bg">';
                }
                $output .= '<span><h5>' . get_the_title() . '</h5></span>';
                if (has_post_thumbnail(get_the_ID())) {
                    $output .= '</div>';
                } else {
                    $output .= '</div>';
                }
                $output .= '</a>';
            }
            $output .= '</div></section>';
        }
    }
    wp_reset_postdata();
    return $output;
}
Esempio n. 15
0
function placeTabboxContents($tb_query_args)
{
    //Filters are added (and later removed) to change the output of The Loop function calls.
    $tb_query = new WP_Query($tb_query_args);
    $output;
    //START CONTENT OUTPUT
    $output .= '
		<div class="tb-selector-bar">';
    //Add selector bar title filter.
    add_filter('the_title', 'tb_title');
    if ($tb_query->have_posts()) {
        while ($tb_query->have_posts()) {
            $tb_query->the_post();
            $output .= get_the_title($tb_query->post->ID);
        }
    }
    $output .= '
		</div>';
    //Remove selector bar title filter.
    remove_filter('the_title', 'tb_title');
    //Add filters for actual content
    add_filter('the_title', 'tbc_title');
    add_filter('the_content', 'tb_content');
    add_filter('post_thumbnail_html', 'tb_thumbnail');
    $tb_query->rewind_posts();
    if ($tb_query->have_posts()) {
        while ($tb_query->have_posts()) {
            $tb_query->the_post();
            global $more;
            $more = 0;
            $output .= '
			<div class="tb-content">';
            $output .= get_the_title($tb_query->post->ID);
            get_the_post_thumbnail($tb_query->post->ID, array(250, 250));
            $content = get_the_content('<span class="readmore">Read More &raquo;</span>');
            $content = apply_filters('the_content', $content);
            $output .= str_replace(']]>', ']]&gt;', $content);
            $output .= '
			</div>';
        }
    }
    //END CONTENT OUTPUT
    //Then the filters are removed so they don't change other posts.
    remove_filter('the_title', 'tbc_title');
    remove_filter('the_content', 'tb_content');
    remove_filter('post_thumbnail_html', 'tb_thumbnail');
    return $output;
}
 function widget($args, $instance)
 {
     if (!isset($instance['format'])) {
         $instance['format'] = 0;
     }
     echo $args['before_widget'];
     echo '<div class="veu_newPosts pt_' . $instance['format'] . '">';
     echo $args['before_title'];
     if (isset($instance['label']) && $instance['label']) {
         echo $instance['label'];
     } else {
         _e('Recent Posts', 'vkExUnit');
     }
     echo $args['after_title'];
     $count = isset($instance['count']) && $instance['count'] ? $instance['count'] : 10;
     $post_type = isset($instance['post_type']) && $instance['post_type'] ? $instance['post_type'] : 'post';
     if ($instance['format']) {
         $this->_taxonomy_init($post_type);
     }
     $p_args = array('post_type' => $post_type, 'posts_per_page' => $count, 'paged' => 1);
     if (isset($instance['terms']) && $instance['terms']) {
         $taxonomies = get_taxonomies(array());
         $p_args['tax_query'] = array('relation' => 'OR');
         foreach ($taxonomies as $taxonomy) {
             $p_args['tax_query'][] = array('taxonomy' => $taxonomy, 'field' => 'id', 'terms' => $instance['terms']);
         }
     }
     $post_loop = new WP_Query($p_args);
     if ($post_loop->have_posts()) {
         if (!$instance['format']) {
             while ($post_loop->have_posts()) {
                 $post_loop->the_post();
                 $this->display_pattern_0();
             }
         } else {
             echo '<ul class="postList">';
             while ($post_loop->have_posts()) {
                 $post_loop->the_post();
                 $this->display_pattern_1();
             }
             echo '</ul>';
         }
     }
     echo '</div>';
     echo $args['after_widget'];
     wp_reset_postdata();
     wp_reset_query();
 }
Esempio n. 17
0
function rum_post_cta_meta_box_list()
{
    global $post;
    // store global post object for later resetting after our query
    // using wp_reset_postdata() doesn't work so we are manually resetting the global
    $post_old = $post;
    // initialize variables
    $options = '';
    // get plugin option array and store in a variable
    $plugin_option_array = get_option('rum_post_cta_plugin_options');
    // fetch values from the plugin option variable array
    $post_cta_post_type = $plugin_option_array['post_type'];
    // retrieve the custom meta box value
    $post_cta_id = get_post_meta($post->ID, 'rum_post_cta_id', true);
    // set query arguments
    $args = array('post_type' => $post_cta_post_type, 'nopaging' => true);
    // execute the query
    $cta_post_query = new WP_Query($args);
    // The Loop
    while ($cta_post_query->have_posts()) {
        $cta_post_query->the_post();
        $post_title = get_the_title();
        $post_ID = get_the_id();
        $options .= '<option value="' . esc_attr($post_ID) . '" ' . selected($post_cta_id, $post_ID) . '>' . $post_title . '</option>';
    }
    // restore the global $post variable of the main query loop
    // wp_reset_postdata(); doesn't work so we are manually resetting it back
    // restore global post object
    $post = $post_old;
    setup_postdata($post);
    return $options;
}
Esempio n. 18
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;
    }
    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;
    }
 /**
  * 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'];
 }
Esempio n. 21
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();
}
Esempio n. 22
0
 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();
     }
 }
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();
}
Esempio n. 24
0
 /**
  *
  */
 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);
 }
Esempio n. 25
0
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>';
}
Esempio n. 26
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;
}
Esempio n. 27
0
 function widget($args, $instance)
 {
     extract($args, EXTR_SKIP);
     $title = empty($instance['title']) ? '' : apply_filters('widget_title', $instance['title']);
     $sticky = get_option('sticky_posts');
     $number = empty($instance['number']) ? 1 : (int) $instance['number'];
     $cat = empty($instance['category']) ? 0 : (int) $instance['category'];
     if (is_single()) {
         array_push($sticky, get_the_ID());
     }
     echo $before_widget;
     if (!empty($title)) {
         echo $before_title . $title . $after_title;
     } else {
         echo '<br />';
     }
     $featuredPosts = new WP_Query(array('posts_per_page' => $number, 'cat' => $cat, 'post__not_in' => $sticky, 'no_found_rows' => true));
     while ($featuredPosts->have_posts()) {
         $featuredPosts->the_post();
         global $mb_content_area, $more;
         $mb_content_area = 'sidebar';
         get_template_part('content', get_post_format());
     }
     wp_reset_postdata();
     echo $after_widget;
 }
 /**
  * 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();
 }
 /**
  * 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;
 }
Esempio n. 30
-7
 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;
 }