当前位置: 首页>>代码示例>>PHP>>正文


PHP my_string_limit_words函数代码示例

本文整理汇总了PHP中my_string_limit_words函数的典型用法代码示例。如果您正苦于以下问题:PHP my_string_limit_words函数的具体用法?PHP my_string_limit_words怎么用?PHP my_string_limit_words使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了my_string_limit_words函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: widget

    /** @see WP_Widget::widget */
    function widget($args, $instance)
    {
        extract($args);
        $title = apply_filters('widget_title', $instance['title']);
        $category = apply_filters('widget_category', $instance['category']);
        $post_format = apply_filters('widget_post_format', $instance['post_format']);
        $linktext = apply_filters('widget_linktext', $instance['linktext']);
        $linkurl = apply_filters('widget_linkurl', $instance['linkurl']);
        $count = apply_filters('widget_count', $instance['count']);
        $excerpt_count = apply_filters('widget_excerpt_count', $instance['excerpt_count']);
        ?>
              <?php 
        echo $before_widget;
        ?>
                  <?php 
        if ($title) {
            echo $before_title . $title . $after_title;
        }
        ?>
						
						
						
						<?php 
        if ($post_format == 'post-format-standard') {
            $args = array('showposts' => $count, 'category_name' => $category, 'tax_query' => array('relation' => 'AND', array('taxonomy' => 'post_format', 'field' => 'slug', 'terms' => array('post-format-aside', 'post-format-gallery', 'post-format-link', 'post-format-image', 'post-format-quote', 'post-format-audio', 'post-format-video'), 'operator' => 'NOT IN')));
        } else {
            $args = array('showposts' => $count, 'category_name' => $category, 'tax_query' => array('relation' => 'AND', array('taxonomy' => 'post_format', 'field' => 'slug', 'terms' => array($post_format))));
        }
        ?>
						
						
						
						
						
						<?php 
        $wp_query = new WP_Query($args);
        ?>
						
								<ul class="latestpost">
								
								<?php 
        if ($wp_query->have_posts()) {
            while ($wp_query->have_posts()) {
                $wp_query->the_post();
                ?>
								
								<li class="clearfix">
                  <time datetime="<?php 
                the_time('Y-m-d\\TH:i');
                ?>
"><?php 
                the_time('j');
                ?>
<span class="month"><?php 
                the_time('M');
                ?>
</span></time>
                  <h4><a href="<?php 
                the_permalink();
                ?>
" rel="bookmark" title="<?php 
                _e('Permanent Link to', 'theme1762');
                ?>
 <?php 
                the_title_attribute();
                ?>
"><?php 
                the_title();
                ?>
</a></h4>
									<?php 
                if ($excerpt_count != "") {
                    ?>
									<div class="excerpt">
                  <?php 
                    $excerpt = get_the_excerpt();
                    echo my_string_limit_words($excerpt, $excerpt_count);
                    ?>
									</div>
									<?php 
                }
                ?>
								</li>
								<?php 
            }
            ?>
								</ul>
								<?php 
        }
        ?>
								
								<?php 
        $wp_query = null;
        $wp_query = $temp;
        ?>
								
								
								<!-- Link under post cycle -->
								<?php 
//.........这里部分代码省略.........
开发者ID:hoangluanlee,项目名称:dlbh,代码行数:101,代码来源:my-recent-posts.php

示例2: posts_grid_shortcode

 function posts_grid_shortcode($atts, $content = null, $shortcodename = '')
 {
     extract(shortcode_atts(array('type' => 'post', 'category' => '', 'custom_category' => '', 'tag' => '', 'columns' => '3', 'rows' => '3', 'order_by' => 'date', 'order' => 'DESC', 'thumb_width' => '370', 'thumb_height' => '250', 'meta' => '', 'excerpt_count' => '15', 'link' => 'yes', 'link_text' => __('Read more', CHERRY_PLUGIN_DOMAIN), 'custom_class' => ''), $atts));
     $spans = $columns;
     $rand = rand();
     // columns
     switch ($spans) {
         case '1':
             $spans = 'span12';
             break;
         case '2':
             $spans = 'span6';
             break;
         case '3':
             $spans = 'span4';
             break;
         case '4':
             $spans = 'span3';
             break;
         case '6':
             $spans = 'span2';
             break;
     }
     // check what order by method user selected
     switch ($order_by) {
         case 'date':
             $order_by = 'post_date';
             break;
         case 'title':
             $order_by = 'title';
             break;
         case 'popular':
             $order_by = 'comment_count';
             break;
         case 'random':
             $order_by = 'rand';
             break;
     }
     // check what order method user selected (DESC or ASC)
     switch ($order) {
         case 'DESC':
             $order = 'DESC';
             break;
         case 'ASC':
             $order = 'ASC';
             break;
     }
     // show link after posts?
     switch ($link) {
         case 'yes':
             $link = true;
             break;
         case 'no':
             $link = false;
             break;
     }
     global $post;
     global $my_string_limit_words;
     $numb = $columns * $rows;
     // WPML filter
     $suppress_filters = get_option('suppress_filters');
     $args = array('post_type' => $type, 'category_name' => $category, $type . '_category' => $custom_category, 'tag' => $tag, 'numberposts' => $numb, 'orderby' => $order_by, 'order' => $order, 'suppress_filters' => $suppress_filters);
     $posts = get_posts($args);
     $i = 0;
     $count = 1;
     $output_end = '';
     $countul = 0;
     if ($numb > count($posts)) {
         $output_end = '</ul>';
     }
     $output = '<ul class="posts-grid row-fluid unstyled ' . $custom_class . ' ul-item-' . $countul . '">';
     foreach ($posts as $j => $post) {
         $post_id = $posts[$j]->ID;
         //Check if WPML is activated
         if (defined('ICL_SITEPRESS_VERSION')) {
             global $sitepress;
             $post_lang = $sitepress->get_language_for_element($post_id, 'post_' . $type);
             $curr_lang = $sitepress->get_current_language();
             // Unset not translated posts
             if ($post_lang != $curr_lang) {
                 unset($posts[$j]);
             }
             // Post ID is different in a second language Solution
             if (function_exists('icl_object_id')) {
                 $posts[$j] = get_post(icl_object_id($posts[$j]->ID, $type, true));
             }
         }
         setup_postdata($posts[$j]);
         $excerpt = get_the_excerpt();
         $attachment_url = wp_get_attachment_image_src(get_post_thumbnail_id($post_id), 'full');
         $url = $attachment_url['0'];
         $image = aq_resize($url, $thumb_width, $thumb_height, true);
         $mediaType = get_post_meta($post_id, 'tz_portfolio_type', true);
         $prettyType = 0;
         if ($count > $columns) {
             $count = 1;
             $countul++;
             $output .= '<ul class="posts-grid row-fluid unstyled ' . $custom_class . ' ul-item-' . $countul . '">';
         }
         $output .= '<li class="' . $spans . ' list-item-' . $count . '">';
//.........这里部分代码省略.........
开发者ID:hoangluanlee,项目名称:dlbh,代码行数:101,代码来源:posts-grid.php

示例3: shortcode_carousel

	function shortcode_carousel($atts, $content = null) {
			extract(shortcode_atts(array(
				'title' => '',
				'num' => '8',
				'type' => '',
				'thumb' => 'true',
				'thumb_width' => '220',
				'thumb_height' => '180',
				'more_text_single' => theme_locals('read_more'),
				'category' => '',
				'custom_category' => '',
				'excerpt_count' => '12',
				'date' => '',
				'author' => '',			
				'min_items' => '3',
				'spacer'	=> '18',
				'custom_class' => ''
			), $atts));

			$template_url = get_stylesheet_directory_uri();
			
			// check what type of post user selected
			switch ($type) {
			   	case 'blog':
					$type_post = '';
					break;
			   	case 'portfolio':
					$type_post = 'portfolio';
					break;
				case 'testimonial':
					$type_post = 'testi';
					break;
			}		

			$output = '<div class="carousel-wrap '.$custom_class.'">';
			if ($title != '') {
				$output .= '<h2>'.$title.'</h2>';
			}
			$output .= '<div id="carousel-'. $type .'" class="es-carousel-wrapper">';
			$output .= '<div class="es-carousel">';
			$output .= '<ul class="es-carousel_list unstyled">';
			
			global $post;
			global $my_string_limit_words;
			
			$args = array(
				'post_type' => $type_post,
				'category_name' => $category,
				$type_post . '_category' => $custom_category,
				'numberposts' => $num,
				'orderby' => 'post_date',
				'order' => 'DESC'
			);

			$latest = get_posts($args);
			$i = 0;
			
			foreach($latest as $post) {
				setup_postdata($post);
				$excerpt = get_the_excerpt();
				$format = get_post_format();
				$attachment_url = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'full' );
				$url = $attachment_url['0'];
				$image = aq_resize($url, $thumb_width, $thumb_height, true);
				$link_format_url =  get_post_meta(get_the_ID(), 'tz_link_url', true);		

				$output .= '<li class="es-carousel_li '.$format.'">';				
					
					if ($thumb == 'true') {
						if (has_post_thumbnail($post->ID) && $format == 'image') {
												
							$prettyType = 'prettyPhoto';				
							$output .= '<figure class="featured-thumbnail">';
							$output .= '<a href="'.get_permalink($post->ID).'" title="'.get_the_title($post->ID).'">';
							$output .= '<img  src="'.$image.'" alt="'.get_the_title($post->ID).'" />';
							$output .= '</a></figure>';

						} elseif ( $format != 'video' && $format != 'audio') {						

							$thumbid = 0;
							$thumbid = get_post_thumbnail_id($post->ID);
							$images = get_children( array(
								'orderby' => 'menu_order',
								'order' => 'ASC',
								'post_type' => 'attachment',
								'post_parent' => $post->ID,
								'post_mime_type' => 'image',
								'post_status' => null,
								'numberposts' => -1
							) ); 

							if ( $images ) {

								$k = 0;
								//looping through the images
								foreach ( $images as $attachment_id => $attachment ) {					
									//if( $attachment->ID == $thumbid ) continue;

									$image_attributes = wp_get_attachment_image_src( $attachment_id, 'full' ); // returns an array
									$img = aq_resize($image_attributes[0], $thumb_width, $thumb_height, true);  //resize & crop img
//.........这里部分代码省略.........
开发者ID:kevinreilly,项目名称:mendelements.com,代码行数:101,代码来源:carousel.php

示例4: shortcode_carousel

    function shortcode_carousel($atts, $content = null)
    {
        wp_enqueue_script('elastislide', CHERRY_PLUGIN_URL . 'includes/assets/js/jquery.elastislide.js', array('jquery'), '1', true);
        wp_enqueue_script('easing', CHERRY_PLUGIN_URL . 'includes/assets/js/jquery.easing.1.3.js', array('jquery'), '1.3', true);
        extract(shortcode_atts(array('title' => '', 'num' => '8', 'type' => '', 'thumb' => 'true', 'thumb_width' => '220', 'thumb_height' => '180', 'more_text_single' => __('Read more', CHERRY_PLUGIN_DOMAIN), 'category' => '', 'custom_category' => '', 'excerpt_count' => '12', 'date' => '', 'author' => '', 'min_items' => '3', 'spacer' => '18', 'custom_class' => ''), $atts));
        $template_url = get_stylesheet_directory_uri();
        // check what type of post user selected
        switch ($type) {
            case 'blog':
                $type_post = 'post';
                break;
            case 'portfolio':
                $type_post = 'portfolio';
                break;
            case 'testimonial':
                $type_post = 'testi';
                break;
        }
        $output = '<div class="carousel-wrap ' . $custom_class . '">';
        if ($title != '') {
            $output .= '<h2>' . $title . '</h2>';
        }
        $output .= '<div id="carousel-' . $type . '" class="es-carousel-wrapper">';
        $output .= '<div class="es-carousel">';
        $output .= '<ul class="es-carousel_list unstyled">';
        global $post;
        global $my_string_limit_words;
        // WPML filter
        $suppress_filters = get_option('suppress_filters');
        $args = array('post_type' => $type_post, 'category_name' => $category, $type_post . '_category' => $custom_category, 'numberposts' => $num, 'orderby' => 'post_date', 'order' => 'DESC', 'suppress_filters' => $suppress_filters);
        $latest = get_posts($args);
        $i = 0;
        foreach ($latest as $key => $post) {
            // Unset not translated posts
            if (function_exists('wpml_get_language_information')) {
                global $sitepress;
                $check = wpml_get_language_information($post->ID);
                $language_code = substr($check['locale'], 0, 2);
                if ($language_code != $sitepress->get_current_language()) {
                    unset($latest[$key]);
                }
                // Post ID is different in a second language Solution
                if (function_exists('icl_object_id')) {
                    $post = get_post(icl_object_id($post->ID, $type_post, true));
                }
            }
            setup_postdata($post);
            $excerpt = get_the_excerpt();
            $format = get_post_format();
            $attachment_url = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'full');
            $url = $attachment_url['0'];
            $image = aq_resize($url, $thumb_width, $thumb_height, true);
            $link_format_url = get_post_meta(get_the_ID(), 'tz_link_url', true);
            $output .= '<li class="es-carousel_li ' . $format . '">';
            if ($thumb == 'true') {
                if (has_post_thumbnail($post->ID) && $format == 'image') {
                    $output .= '<figure class="featured-thumbnail">';
                    $output .= '<a href="' . get_permalink($post->ID) . '" title="' . get_the_title($post->ID) . '">';
                    $output .= '<img  src="' . $image . '" alt="' . get_the_title($post->ID) . '" />';
                    $output .= '</a></figure>';
                } elseif ($format != 'video' && $format != 'audio') {
                    $thumbid = 0;
                    $thumbid = get_post_thumbnail_id($post->ID);
                    $images = get_children(array('orderby' => 'menu_order', 'order' => 'ASC', 'post_type' => 'attachment', 'post_parent' => $post->ID, 'post_mime_type' => 'image', 'post_status' => null, 'numberposts' => -1));
                    if ($images) {
                        $k = 0;
                        //looping through the images
                        foreach ($images as $attachment_id => $attachment) {
                            //if( $attachment->ID == $thumbid ) continue;
                            $image_attributes = wp_get_attachment_image_src($attachment_id, 'full');
                            // returns an array
                            $img = aq_resize($image_attributes[0], $thumb_width, $thumb_height, true);
                            //resize & crop img
                            $alt = get_post_meta($attachment->ID, '_wp_attachment_image_alt', true);
                            $image_title = $attachment->post_title;
                            if ($k == 0) {
                                $output .= '<figure class="featured-thumbnail">';
                                $output .= '<a href="' . get_permalink($post->ID) . '" title="' . get_the_title($post->ID) . '">';
                                $output .= '<img src="' . $img . '" alt="' . get_the_title($post->ID) . '" />';
                            } else {
                                $output .= '<figure class="featured-thumbnail" style="display:none;">';
                                $output .= '<a href="' . get_permalink($post->ID) . '" title="' . get_the_title($post->ID) . '">';
                                $output .= '<img src="' . $img . '" alt="' . get_the_title($post->ID) . '" />';
                            }
                            $output .= '</a></figure>';
                            $k++;
                        }
                    } elseif (has_post_thumbnail($post->ID)) {
                        $output .= '<figure class="featured-thumbnail">';
                        $output .= '<a href="' . get_permalink($post->ID) . '" title="' . get_the_title($post->ID) . '">';
                        $output .= '<img src="' . $image . '" alt="' . get_the_title($post->ID) . '" />';
                        $output .= '</a></figure>';
                    }
                    /*else {
                    			// empty_featured_thumb.gif - for post without featured thumbnail
                    			$output .= '<figure class="featured-thumbnail">';
                    			$output .= '<a href="'.get_permalink($post->ID).'" title="'.get_the_title($post->ID).'">';
                    			$output .= '<img  src="'.$template_url.'/images/empty_thumb.gif" alt="'.get_the_title($post->ID).'" />';
                    			$output .= '</a></figure>';
                    		}*/
//.........这里部分代码省略.........
开发者ID:rafaelfranco,项目名称:gruporota_portal,代码行数:101,代码来源:carousel.php

示例5: the_title

            $title = the_title('', '', FALSE);
            echo substr($title, 0, 40);
            ?>
</a></h3>
				<?php 
        }
        ?>


				<?php 
        if ($folio_excerpt == "yes") {
            ?>

					<p class="excerpt"><?php 
            $excerpt = get_the_excerpt();
            echo my_string_limit_words($excerpt, $folio_excerpt_count);
            ?>
</p>
				<?php 
        }
        ?>

				
				<?php 
        if ($folio_btn == "yes") {
            $button_text = of_get_option('folio_button_text') ? of_get_option('folio_button_text') : theme_locals("read_more");
            ?>

					<p><a href="<?php 
            the_permalink();
            ?>
开发者ID:poolieweb,项目名称:LawStaticAthena,代码行数:31,代码来源:filterable-portfolio-loop.php

示例6: widget


//.........这里部分代码省略.........
                        ?>
                    <a href="<?php 
                        the_permalink();
                        ?>
">
                  <?php 
                    }
                    ?>
                <?php 
                    the_excerpt();
                    ?>
				  <?php 
                    if ($instance['excerpt_as_link']) {
                        ?>
                    </a>
                  <?php 
                    }
                    ?>
              <?php 
                } else {
                    ?>
				  <?php 
                    if ($instance['excerpt_as_link']) {
                        ?>
                    <a href="<?php 
                        the_permalink();
                        ?>
">
                  <?php 
                    }
                    ?>
                <?php 
                    $excerpt = get_the_excerpt();
                    echo my_string_limit_words($excerpt, $limittext);
                    ?>
				  <?php 
                    if ($instance['excerpt_as_link']) {
                        ?>
                    </a>
                  <?php 
                    }
                    ?>
              <?php 
                }
                ?>
            <?php 
            }
            ?>
            </div>
			<?php 
            if ($instance['posttype'] == "testi") {
                ?>
              <div class="name-testi"><span class="user"><?php 
                echo $testiname;
                ?>
</span>, <a href="http://<?php 
                echo $testiurl;
                ?>
"><?php 
                echo $testiurl;
                ?>
</a></div>
            <?php 
            }
            ?>
            <?php 
开发者ID:repeater,项目名称:Synergy,代码行数:67,代码来源:my-posts-type-widget.php

示例7: the_permalink

" /></a></span>
        <?php 
        }
        ?>
        <div class="folio-desc">
          <h3><a href="<?php 
        the_permalink();
        ?>
"><?php 
        $title = the_title('', '', FALSE);
        echo substr($title, 0, 40);
        ?>
</a></h3>
          <?php 
        $content = get_the_content();
        echo my_string_limit_words($content, 23);
        ?>
        </div>
      </li>
    
  
    <?php 
        $i++;
        $addclass = "";
    }
}
?>
  </ul>
  <div class="clear"></div>
</div>
开发者ID:hoangluanlee,项目名称:dlbh,代码行数:30,代码来源:page-Portfolio3Cols.php

示例8: shortcode_recenttesti

function shortcode_recenttesti($atts, $content = null)
{
    extract(shortcode_atts(array('num' => '5', 'thumb' => 'true', 'excerpt_count' => '30', 'custom_class' => ''), $atts));
    // WPML filter
    $suppress_filters = get_option('suppress_filters');
    $args = array('post_type' => 'testi', 'numberposts' => $num, 'orderby' => 'post_date', 'suppress_filters' => $suppress_filters);
    $testi = get_posts($args);
    $output = '<div class="testimonials ' . $custom_class . '">';
    global $post;
    global $my_string_limit_words;
    foreach ($testi as $k => $post) {
        // Unset not translated posts
        if (function_exists('wpml_get_language_information')) {
            global $sitepress;
            $check = wpml_get_language_information($post->ID);
            $language_code = substr($check['locale'], 0, 2);
            if ($language_code != $sitepress->get_current_language()) {
                unset($testi[$k]);
            }
            // Post ID is different in a second language Solution
            if (function_exists('icl_object_id')) {
                $post = get_post(icl_object_id($post->ID, 'testi', true));
            }
        }
        setup_postdata($post);
        $excerpt = get_the_excerpt();
        $testiname = get_post_meta(get_the_ID(), 'my_testi_caption', true);
        $testiurl = get_post_meta(get_the_ID(), 'my_testi_url', true);
        $testiinfo = get_post_meta(get_the_ID(), 'my_testi_info', true);
        $attachment_url = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'full');
        $url = $attachment_url['0'];
        $image = aq_resize($url, 280, 240, true);
        $output .= '<div class="testi-item">';
        $output .= '<div class="testi-meta">';
        if (isset($testiname)) {
            $output .= '<div class="user">';
            $output .= $testiname;
            $output .= '</div>';
        }
        if (isset($testiinfo)) {
            $output .= '<div class="info">(';
            $output .= $testiinfo;
            $output .= ')</div>';
        }
        $output .= '</div>';
        $output .= '<blockquote class="testi-item_blockquote">';
        if ($thumb == 'true') {
            if (has_post_thumbnail($post->ID)) {
                $output .= '<figure class="featured-thumbnail">';
                $output .= '<img src="' . $image . '" alt="" />';
                $output .= '</figure>';
            }
        }
        $output .= '<a href="' . get_permalink($post->ID) . '">';
        $output .= my_string_limit_words($excerpt, $excerpt_count);
        $output .= '</a><span class="close_quote"></span><div class="clear"></div>';
        $output .= '</blockquote>';
        $output .= '</div>';
    }
    wp_reset_postdata();
    // restore the global $post variable
    $output .= '</div>';
    return $output;
}
开发者ID:rafaelfranco,项目名称:gruporota_portal,代码行数:64,代码来源:my_function.php

示例9: widget


//.........这里部分代码省略.........
                        echo get_the_time('Y-m-d\\TH:i:s', $post_id);
                        ?>
"><?php 
                        echo get_the_date();
                        ?>
</time>

							<?php 
                    }
                    // post author
                    if ($show_author) {
                        ?>
								<em class="author">
									<span><?php 
                        _e('by', CHERRY_PLUGIN_DOMAIN);
                        ?>
</span>
									<a href="<?php 
                        echo get_author_posts_url(get_the_author_meta('ID'));
                        ?>
"><?php 
                        echo get_the_author_meta('display_name');
                        ?>
</a>
								</em>
							<?php 
                    }
                    // post title
                    if ($show_title) {
                        ?>
									<h5>
										<a href ="<?php 
                        echo $post_permalink;
                        ?>
" title="<?php 
                        echo $post_title_attr;
                        ?>
" style="color:#009bd9; font-size:20px;"><?php 
                        echo $post_title;
                        ?>
</a>
									</h5>
								<?php 
                    }
                    // post excerpt
                    if ($show_excerpt) {
                        if ($excerpt_count > 0) {
                            ?>
                                        <div style="width: 70%; margin-left:auto; margin-right:auto;">
										    <p class="excerpt" style = "text-align:justify;">
											    <?php 
                            echo my_string_limit_words($excerpt, $excerpt_count);
                            ?>
										    </p>
                                        </div>
									<?php 
                        }
                    }
                    // post comment count
                    if ($show_comments) {
                        $comment_count = $post_cycle->post->comment_count;
                        if ($comment_count > 1) {
                            $comment_count = $comment_count . ' <span>' . __('Comments', CHERRY_PLUGIN_DOMAIN) . '</span>';
                        } else {
                            $comment_count = $comment_count . ' <span>' . __('Comment', CHERRY_PLUGIN_DOMAIN) . '</span>';
                        }
                        echo '<a href="' . $post_permalink . '#comments" class="comments_link" style="text-align:center; font-size:16px;">' . $comment_count . '</a>';
                    }
                    ?>
							</div>
							<?php 
                    // post more button
                    $more_text_single = esc_html(wp_kses_data($more_text_single));
                    if ($more_text_single != '') {
                        ?>
								<a href="<?php 
                        echo get_permalink($post_id);
                        ?>
" title="<?php 
                        echo $post_title_attr;
                        ?>
" class="btn btn-primary"><?php 
                        _e($more_text_single, CHERRY_PLUGIN_DOMAIN);
                        ?>
</a>
							<?php 
                    }
                    ?>
						</li><!-- .slide -->
						<?php 
                }
            }
            ?>
				</ul><!-- .slides -->
			</div><!-- .flexslider -->
			<?php 
            echo $after_widget;
        }
        wp_reset_postdata();
    }
开发者ID:hoangluanlee,项目名称:dlbh,代码行数:101,代码来源:my-post-cycle-widget.php

示例10: mini_posts_list_shortcode

 function mini_posts_list_shortcode($atts, $content = null, $shortcodename = '')
 {
     extract(shortcode_atts(array('type' => 'post', 'numb' => '3', 'thumbs' => '', 'thumb_width' => '', 'thumb_height' => '', 'meta' => '', 'order_by' => '', 'order' => '', 'excerpt_count' => '0', 'custom_class' => ''), $atts));
     $template_url = get_template_directory_uri();
     // check what order by method user selected
     switch ($order_by) {
         case 'date':
             $order_by = 'post_date';
             break;
         case 'title':
             $order_by = 'title';
             break;
         case 'popular':
             $order_by = 'comment_count';
             break;
         case 'random':
             $order_by = 'rand';
             break;
     }
     // check what order method user selected (DESC or ASC)
     switch ($order) {
         case 'DESC':
             $order = 'DESC';
             break;
         case 'ASC':
             $order = 'ASC';
             break;
     }
     // thumbnail size
     $thumb_x = 0;
     $thumb_y = 0;
     if ($thumb_width != '' && $thumb_height != '') {
         $thumbs = 'custom_thumb';
         $thumb_x = $thumb_width;
         $thumb_y = $thumb_height;
     } else {
         switch ($thumbs) {
             case 'small':
                 $thumb_x = 110;
                 $thumb_y = 110;
                 break;
             case 'smaller':
                 $thumb_x = 90;
                 $thumb_y = 90;
                 break;
             case 'smallest':
                 $thumb_x = 60;
                 $thumb_y = 60;
                 break;
         }
     }
     global $post;
     global $my_string_limit_words;
     // WPML filter
     $suppress_filters = get_option('suppress_filters');
     $args = array('post_type' => $type, 'numberposts' => $numb, 'orderby' => $order_by, 'order' => $order, 'suppress_filters' => $suppress_filters);
     $posts = get_posts($args);
     $i = 0;
     $output = '<ul class="mini-posts-list ' . $custom_class . '">';
     foreach ($posts as $key => $post) {
         //Check if WPML is activated
         if (defined('ICL_SITEPRESS_VERSION')) {
             global $sitepress;
             $post_lang = $sitepress->get_language_for_element($post->ID, 'post_' . $type);
             $curr_lang = $sitepress->get_current_language();
             // Unset not translated posts
             if ($post_lang != $curr_lang) {
                 unset($posts[$key]);
             }
             // Post ID is different in a second language Solution
             if (function_exists('icl_object_id')) {
                 $post = get_post(icl_object_id($post->ID, $type, true));
             }
         }
         setup_postdata($post);
         $excerpt = get_the_excerpt();
         $attachment_url = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'full');
         $url = $attachment_url['0'];
         $image = aq_resize($url, $thumb_x, $thumb_y, true);
         $mediaType = get_post_meta($post->ID, 'tz_portfolio_type', true);
         $format = get_post_format();
         //$output .= '<div class="row-fluid">';
         $output .= '<li class="mini-post-holder clearfix list-item-' . $i . '">';
         //post thumbnail
         if ($thumbs != 'none') {
             if (has_post_thumbnail($post->ID) && ($format == 'image' || $mediaType == 'Image')) {
                 $output .= '<figure class="a featured-thumbnail thumbnail ' . $thumbs . '">';
                 $output .= '<a href="' . get_permalink($post->ID) . '" title="' . get_the_title($post->ID) . '">';
                 $output .= '<img src="' . $image . '" alt="' . get_the_title($post->ID) . '" />';
                 $output .= '</a></figure>';
             } elseif ($mediaType != 'Video' && $mediaType != 'Audio') {
                 $thumbid = 0;
                 $thumbid = get_post_thumbnail_id($post->ID);
                 $images = get_children(array('orderby' => 'menu_order', 'order' => 'ASC', 'post_type' => 'attachment', 'post_parent' => $post->ID, 'post_mime_type' => 'image', 'post_status' => null, 'numberposts' => -1));
                 if ($images) {
                     $k = 0;
                     //looping through the images
                     foreach ($images as $attachment_id => $attachment) {
                         //$prettyType = "prettyPhoto[gallery".$i."]";
                         //if( $attachment->ID == $thumbid ) continue;
//.........这里部分代码省略.........
开发者ID:hoangluanlee,项目名称:dlbh,代码行数:101,代码来源:mini-posts-list.php

示例11: widget

    /** @see WP_Widget::widget */
    function widget($args, $instance)
    {
        extract($args);
        $title = apply_filters('widget_title', $instance['title']);
        $category = apply_filters('widget_category', $instance['category']);
        $linktext = apply_filters('widget_linktext', $instance['linktext']);
        $linkurl = apply_filters('widget_linkurl', $instance['linkurl']);
        ?>
              <?php 
        echo $before_widget;
        ?>
                  <?php 
        if ($title) {
            echo $before_title . $title . $after_title;
        }
        ?>
						
								<?php 
        if (have_posts()) {
            ?>
								<ul class="latestpost">
								<?php 
            $querycat = $category;
            ?>
								<?php 
            query_posts("showposts=3&cat=" . $querycat);
            ?>
								<?php 
            while (have_posts()) {
                the_post();
                ?>
	
								<li>
								<a href="<?php 
                the_permalink();
                ?>
" rel="bookmark" title="<?php 
                _e('Permanent Link to', 'my_framework');
                ?>
 <?php 
                the_title_attribute();
                ?>
">
								<span class="smalltext"><?php 
                the_time('F j, Y');
                ?>
</span>
								<h4><?php 
                the_title();
                ?>
</h4>
								<?php 
                $excerpt = get_the_excerpt();
                echo my_string_limit_words($excerpt, 10);
                ?>
<small class="more"><?php 
                _e('more', 'my_framework');
                ?>
 &raquo;</small></a>
								</li>
								<?php 
            }
            ?>
								</ul>
								<?php 
        }
        ?>
								
								
								<!-- Print a link to this category -->
								<?php 
        if ($linkurl != "") {
            ?>
								<span class="text-styled"><a href="<?php 
            echo $linkurl;
            ?>
"><?php 
            echo $linktext;
            ?>
</a></span>
								<?php 
        }
        ?>

								<?php 
        wp_reset_query();
        ?>
								
              <?php 
        echo $after_widget;
        ?>
			 
        <?php 
    }
开发者ID:sangikumar,项目名称:IP,代码行数:95,代码来源:my-recent-posts.php

示例12: widget

    /** @see WP_Widget::widget */
    function widget($args, $instance)
    {
        extract($args);
        $limit = apply_filters('widget_limit', $instance['limit']);
        $count = apply_filters('widget_count', $instance['count']);
        $linktext = apply_filters('widget_linktext', $instance['linktext']);
        ?>
              <?php 
        echo $before_widget;
        ?>
                 	    
				  
				    <div class="banners_cycle" id="banners-cycle">
						<?php 
        $limittext = $limit;
        ?>
						<?php 
        global $more;
        $more = 0;
        $counter = 1;
        ?>
						<?php 
        query_posts("posts_per_page=" . $count . "&post_type=banners");
        ?>
						<?php 
        while (have_posts()) {
            the_post();
            ?>
	
						<?php 
            $custom = get_post_custom($post->ID);
            $bannertitle = $custom["banner-title"][0];
            $buttonurl = $custom["button-url"][0];
            ?>
						<div class="banners_item banners_item_<?php 
            echo $counter;
            ?>
">
							<span class="banner-title"><div class="title-text"><?php 
            echo $bannertitle;
            ?>
</div></span>
							<div class="description">
								<div class="inside">
									<h1><?php 
            the_title();
            ?>
</h1>
									<p><?php 
            $excerpt = get_the_excerpt();
            echo my_string_limit_words($excerpt, $limit);
            ?>
</p>
									
									<?php 
            if ($buttonurl == "") {
                ?>
											<a href="<?php 
                the_permalink();
                ?>
" class="banner-button"><?php 
                if ($linktext == "") {
                    echo 'Read more';
                } else {
                    echo $linktext;
                }
                ?>
</a>
									<?php 
            } else {
                ?>
	
										<a href="<?php 
                echo $buttonurl;
                ?>
" class="banner-button"><?php 
                if ($linktext == "") {
                    echo 'Read more';
                } else {
                    echo $linktext;
                }
                ?>
</a>
									<?php 
            }
            ?>
									
								</div>
							</div>
						</div>
						<?php 
            $counter++;
        }
        ?>
						<?php 
        wp_reset_query();
        ?>
					</div>
				    		
//.........这里部分代码省略.........
开发者ID:anaved,项目名称:wordpress-tinkering,代码行数:101,代码来源:my-banners-widget.php

示例13: the_title

						$image_title = $attachment->post_title;
						?>
							
						<a href="<?php echo $image_attributes[0]; ?>" title="<?php the_title(); ?>" rel="<?php echo $prettyType; ?>" style="display:none;"></a>

					<?php
					}
				} 
			} else { ?>				
				<figure class="thumbnail thumbnail__portfolio">
					<a class="image-wrap" href="<?php the_permalink() ?>" title="<?php echo theme_locals("permanent_link_to"); ?> <?php the_title_attribute(); ?>" ><img src="<?php echo $image ?>" alt="<?php the_title(); ?>" /></a>
				</figure>				
			<?php } ?>		
			
			<!-- Caption -->
			<div class="caption caption__portfolio">
				<?php if($folio_title == "yes"){ ?>
					<h3><a href="<?php the_permalink(); ?>"><?php $title = the_title('','',FALSE); echo substr($title, 0, 40); ?></a></h3>
				<?php } ?>

				<?php if($folio_excerpt == "yes"){ ?>
					<p class="excerpt"><?php $excerpt = get_the_excerpt(); echo my_string_limit_words($excerpt,$folio_excerpt_count);?></p>
				<?php } ?>
				
				<?php if($folio_btn == "yes"){ ?>
					<p><a href="<?php the_permalink() ?>" class="btn btn-primary"><?php echo theme_locals("read_more"); ?></a></p>
				<?php } ?>
			</div><!-- /Caption -->
		</div>
	</li>	
	<?php $i++; endwhile; ?>
开发者ID:kevinreilly,项目名称:mendelements.com,代码行数:31,代码来源:filterable-portfolio-loop.php

示例14: postExcerptBuilder

function postExcerptBuilder($postID, $excerpt_count)
{
    if ($excerpt_count != 0) {
        $output = '';
        if (has_excerpt($postID)) {
            $excerpt = wp_strip_all_tags(get_the_excerpt());
        } else {
            $excerpt = wp_strip_all_tags(strip_shortcodes(get_the_content()));
        }
        if (!empty($excerpt[0])) {
            $output .= $excerpt_count == -1 ? '<p class="excerpt">' . $excerpt . '</p>' : '<p class="excerpt">' . my_string_limit_words($excerpt, $excerpt_count) . '</p>';
        }
        return $output;
    }
}
开发者ID:vanie3,项目名称:tint-my-ride,代码行数:15,代码来源:custom-function.php

示例15: widget


//.........这里部分代码省略.........
                        ?>
				<a href="<?php 
                        the_permalink();
                        ?>
">
			  <?php 
                    }
                    ?>
			<?php 
                    the_excerpt();
                    ?>
		  <?php 
                    if ($instance['excerpt_as_link']) {
                        ?>
				</a>
			  <?php 
                    }
                    ?>
		  <?php 
                } else {
                    ?>
		  <?php 
                    if ($instance['excerpt_as_link']) {
                        ?>
				<a href="<?php 
                        the_permalink();
                        ?>
">
			  <?php 
                    }
                    ?>
			<?php 
                    $excerpt = get_the_excerpt();
                    echo my_string_limit_words($excerpt, $limittext);
                    ?>
		  <?php 
                    if ($instance['excerpt_as_link']) {
                        ?>
				</a>
			  <?php 
                    }
                    ?>
		  <?php 
                }
                ?>
		<?php 
            }
            ?>
	  </div>
			<?php 
            if ($instance['posttype'] == "testi") {
                ?>

			<div class="name-testi">

				<?php 
                if (!empty($testiname)) {
                    ?>
					<span class="user"><?php 
                    echo $testiname;
                    ?>
</span><?php 
                    echo ', ';
                    ?>
				<?php 
                }
开发者ID:vanie3,项目名称:tint-my-ride,代码行数:67,代码来源:my-posts-type-widget.php


注:本文中的my_string_limit_words函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。