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


PHP has_excerpt函数代码示例

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


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

示例1: shadesofgray_custom_excerpt_more

/**
 * Adds "Continue Reading" link to custom post excerpts.
 */
function shadesofgray_custom_excerpt_more($output)
{
    if (has_excerpt() && !is_attachment()) {
        $output .= shadesofgray_continue_reading_link();
    }
    return $output;
}
开发者ID:karan-garg,项目名称:Web-Dev,代码行数:10,代码来源:functions.php

示例2: porto_get_excerpt

function porto_get_excerpt($limit = 45, $more_link = true)
{
    global $porto_settings;
    if (!$limit) {
        $limit = 45;
    }
    if (has_excerpt()) {
        $content = strip_tags(strip_shortcodes(get_the_excerpt()));
    } else {
        $content = strip_tags(strip_shortcodes(get_the_content()));
    }
    $content = explode(' ', $content, $limit);
    if (count($content) >= $limit) {
        array_pop($content);
        if ($more_link) {
            $content = implode(" ", $content) . '... ';
        } else {
            $content = implode(" ", $content) . ' [...]';
        }
    } else {
        $content = implode(" ", $content);
    }
    if ($porto_settings['blog-excerpt-type'] == 'html') {
        $content = apply_filters('the_content', $content);
        $content = do_shortcode($content);
    }
    if ($more_link) {
        $content .= ' <a class="read-more" href="' . esc_url(apply_filters('the_permalink', get_permalink())) . '">' . __('read more', 'porto') . ' <i class="fa fa-angle-right"></i></a>';
    }
    if ($porto_settings['blog-excerpt-type'] != 'html') {
        $content = '<p class="post-excerpt">' . $content . '</p>';
    }
    return $content;
}
开发者ID:prosenjit-itobuz,项目名称:Unitee,代码行数:34,代码来源:post.php

示例3: output

    function output($options)
    {
        global $dslc_active;
        $post_id = $options['post_id'];
        if ($dslc_active && is_user_logged_in() && current_user_can(DS_LIVE_COMPOSER_CAPABILITY)) {
            $dslc_is_admin = true;
        } else {
            $dslc_is_admin = false;
        }
        if ($dslc_is_admin) {
            $the_excerpt = __('Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.', 'live-composer-page-builder');
        } else {
            $the_excerpt = false;
        }
        if (is_singular() && get_post_type() !== 'dslc_templates' && has_excerpt()) {
            $post_id = get_the_ID();
            $post = get_post($post_id);
            $the_excerpt = apply_filters('get_the_excerpt', $post->post_excerpt);
        }
        $this->module_start($options);
        /* Module output starts here */
        if ($the_excerpt) {
            ?>
<div class="dslc-tp-excerpt"><?php 
            echo $the_excerpt;
            ?>
</div><?php 
        }
        /* Module output ends here */
        $this->module_end($options);
    }
开发者ID:webeau,项目名称:Live-Composer,代码行数:31,代码来源:module.php

示例4: iced_mocha_custom_excerpt_more

/**
 * Adds a pretty "Continue Reading" link to custom post excerpts.
 *
 * To override this link in a child theme, remove the filter and add your own
 * function tied to the get_the_excerpt filter hook.
 *
 * @since iced_mocha 0.5
 * @return string Excerpt with a pretty "Continue Reading" link
 */
function iced_mocha_custom_excerpt_more($output)
{
    if (has_excerpt() && !is_attachment() && !get_post_type() == 'espresso_events') {
        $output .= iced_mocha_continue_reading_link();
    }
    return $output;
}
开发者ID:JBNavadiya,项目名称:iced-mocha,代码行数:16,代码来源:theme-loop.php

示例5: italystrap_custom_excerpt_more

 function italystrap_custom_excerpt_more($output)
 {
     if (has_excerpt() && !is_attachment()) {
         $output .= italystrap_read_more_link();
     }
     return $output;
 }
开发者ID:AndrGelmini,项目名称:ItalyStrap,代码行数:7,代码来源:custom_excerpt.php

示例6: minileven_custom_excerpt_more

/**
 * Adds a pretty "Continue Reading" link to custom post excerpts.
 *
 * To override this link in a child theme, remove the filter and add your own
 * function tied to the get_the_excerpt filter hook.
 */
function minileven_custom_excerpt_more($output)
{
    if (has_excerpt() && !is_attachment()) {
        $output .= minileven_continue_reading_link();
    }
    return $output;
}
开发者ID:KurtMakesWeb,项目名称:CandG,代码行数:13,代码来源:tweaks.php

示例7: bootstrapthreeminimal_custom_excerpt_more

/**
 * Adds a pretty "Continue Reading" link to custom post excerpts.
 */
function bootstrapthreeminimal_custom_excerpt_more($output)
{
    if (has_excerpt() && !is_attachment()) {
        $output .= bootstrapthreeminimal_continue_reading_link();
    }
    return $output;
}
开发者ID:aptiko,项目名称:wordpress-bootstrap3-minimal,代码行数:10,代码来源:functions.php

示例8: airmozilla_custom_excerpt_more

/**
 * Adds a pretty "Continue Reading" link to custom post excerpts.
 *
 * To override this link in a child theme, remove the filter and add your own
 * function tied to the get_the_excerpt filter hook.
 */
function airmozilla_custom_excerpt_more($output)
{
    if (has_excerpt() && !is_attachment()) {
        $output .= airmozilla_continue_reading_link();
    }
    return $output;
}
开发者ID:guspit,项目名称:One-Mozilla-blog,代码行数:13,代码来源:functions.php

示例9: addWidgetForExcerpt

 /**
  * Adds toolbox to excerpts wp pages -- can't use addWidget straight out
  * because when the filter on get_the_excerpt is added, it doesn't yet know
  * if it has an excerpt or not
  *
  * @param string $content Page contents
  * @return string Page content with our sharing button HTML added
  */
 public function addWidgetForExcerpt($content)
 {
     if (has_excerpt() || !is_single()) {
         $content = $this->addWidget($content);
     }
     return $content;
 }
开发者ID:OneTimeUser,项目名称:retailwire,代码行数:15,代码来源:addthis-toolbox.php

示例10: swp_get_excerpt_by_id

function swp_get_excerpt_by_id($post_id)
{
    // Check if the post has an excerpt
    if (has_excerpt()) {
        $the_post = get_post($post_id);
        //Gets post ID
        $the_excerpt = $the_post->post_excerpt;
        // If not, let's create an excerpt
    } else {
        $the_post = get_post($post_id);
        //Gets post ID
        $the_excerpt = $the_post->post_content;
        //Gets post_content to be used as a basis for the excerpt
    }
    $excerpt_length = 100;
    //Sets excerpt length by word count
    $the_excerpt = strip_tags(strip_shortcodes($the_excerpt));
    //Strips tags and images
    $the_excerpt = str_replace(']]>', ']]&gt;', $the_excerpt);
    $the_excerpt = strip_tags($the_excerpt);
    $excerpt_length = apply_filters('excerpt_length', 100);
    $excerpt_more = apply_filters('excerpt_more', ' ' . '[...]');
    $words = preg_split("/[\n\r\t ]+/", $the_excerpt, $excerpt_length + 1, PREG_SPLIT_NO_EMPTY);
    if (count($words) > $excerpt_length) {
        array_pop($words);
        // array_push($words, '…');
        $the_excerpt = implode(' ', $words);
    }
    $the_excerpt = preg_replace("/\r|\n/", "", $the_excerpt);
    return $the_excerpt;
}
开发者ID:warfare-plugins,项目名称:social-warfare,代码行数:31,代码来源:excerpt.php

示例11: pbosfc_post_excerpt

/**
 * Based (with preserved compatibility) on Storefront Blog Excerpts plugin.
 */
function pbosfc_post_excerpt()
{
    if (!pbosfc_get_option('post_excerpt')) {
        storefront_post_content();
    } else {
        ?>
		<div class="entry-content" itemprop="articleBody">
			<?php 
        if (has_post_thumbnail()) {
            $thumb_size = pbosfc_get_option('excerpt_image_size');
            if ($thumb_size !== 'none') {
                $img_class = $thumb_size == 'thumbnail' ? apply_filters('woa_sf_blog_excerpt_image_float', pbosfc_get_option('excerpt_image_float')) : '';
                the_post_thumbnail($thumb_size, array('itemprop' => 'image', 'class' => "attachment-{$thumb_size} {$img_class}"));
            }
        }
        $content = do_shortcode(has_excerpt(get_the_ID()) ? get_the_excerpt() : get_the_content());
        $content = wp_trim_words($content, pbosfc_get_option('excerpt_word_count'), __('...', 'pbosfc'));
        echo apply_filters('the_excerpt', $content);
        ?>
			<p class="read-more"><a class="button"
			                        href="<?php 
        the_permalink();
        ?>
"><?php 
        echo __('Continue reading', 'pbosfc');
        ?>
</a>
			</p>
		</div><!-- .entry-content -->
		<?php 
    }
}
开发者ID:boguslawski-piotr,项目名称:pbo-storefront-compact,代码行数:35,代码来源:post.php

示例12: homepage_slider

    function homepage_slider()
    {
        query_posts(array('posts_per_page' => -1, 'post__in' => get_option('sticky_posts'), 'meta_key' => '_thumbnail_id'));
        ?>
		<?php 
        if (have_posts()) {
            ?>
			<style>
				.bx-slider{display:none;}
			</style>
			<ul class="bx-slider">
				<?php 
            while (have_posts()) {
                the_post();
                echo '<li><a href="' . get_permalink() . '">';
                echo '<span class="bx-caption">';
                the_title('<h1>', '</h1>');
                if (has_excerpt()) {
                    echo '<p>';
                    the_excerpt();
                    echo '</p>';
                }
                echo '</span>';
                the_post_thumbnail('full', 'title="' . get_the_title() . '"');
                echo '</a></li>';
            }
            ?>
			</ul>
			<?php 
        }
        wp_reset_query();
    }
开发者ID:pootlepress,项目名称:18tags-slider-add-on,代码行数:32,代码来源:slider-18tags.php

示例13: cosmic_custom_excerpt_more

function cosmic_custom_excerpt_more($output)
{
    if (has_excerpt() && !is_attachment()) {
        $output .= cosmic_reading_link();
    }
    return $output;
}
开发者ID:djmacguyver,项目名称:cosmic-wordpress-tools,代码行数:7,代码来源:cosmic-common.php

示例14: momtaz_get_post_class

/**
 * Creates a set of classes for each site entry upon display. Each entry is given the class of
 * 'hentry'. Posts are given category, tag, and author classes. Alternate post classes of odd,
 * even, and alt are added.
 *
 * @param string|array $class One or more classes to add to the class list.
 * @param int $post_id An optional post ID.
 * @return array
 * @since 1.1
 */
function momtaz_get_post_class($class = '', $post_id = 0)
{
    $classes = array();
    // Get post object
    $post = get_post($post_id);
    if (empty($post)) {
        return $classes;
    }
    // hAtom compliance.
    $classes[] = 'hentry';
    // Get post context.
    $context = momtaz_get_post_context($post_id);
    // Merge the classes array with post context.
    $classes = array_merge($classes, (array) $context);
    // Post taxonomies
    $post_taxonomies = get_post_taxonomies($post);
    if (!empty($post_taxonomies)) {
        foreach ($post_taxonomies as $taxonomy) {
            $terms = get_the_terms($post->ID, $taxonomy);
            if (!empty($terms)) {
                foreach ($terms as $term) {
                    $classes[] = 'term-' . sanitize_html_class($term->slug, $term->term_id);
                }
            }
        }
    }
    // Sticky posts.
    if (is_home() && !is_paged() && is_sticky($post->ID)) {
        $classes[] = 'sticky';
    }
    // Is this post protected by a password?
    if (post_password_required($post)) {
        $classes[] = 'post-password-required';
    }
    // Post alt class.
    if (!momtaz_is_the_single($post)) {
        static $post_alt = 0;
        $classes[] = 'set-' . ++$post_alt;
        $classes[] = $post_alt % 2 ? 'odd' : 'even';
    }
    // Has a custom excerpt?
    if (has_excerpt($post)) {
        $classes[] = 'has-excerpt';
    }
    // Custom classes.
    if (!empty($class)) {
        if (!is_array($class)) {
            $class = preg_split('#\\s+#', $class);
        }
        $classes = array_merge($classes, $class);
    }
    // Apply the WordPress filters.
    $classes = apply_filters('post_class', $classes, $class, $post->ID);
    // Apply the Momtaz FW filters.
    $classes = apply_filters('momtaz_get_post_class', $classes, $post);
    // Removes any duplicate and empty classes.
    $classes = array_unique(array_filter($classes));
    return $classes;
}
开发者ID:emados,项目名称:Momtaz-Framework,代码行数:69,代码来源:entries.php

示例15: widget

    /**
     * Displays the widget content
     *
     * @author	Konstantin Obeland
     * @since	1.1.0 - 08.03.2012
     * @access	public
     *
     * @param	array	$args
     * @param	array	$instance
     *
     * @return	void
     */
    public function widget($args, $instance)
    {
        if (!has_post_format('gallery', $instance['post_id'])) {
            return;
        }
        $attachments = get_children(array('post_parent' => $instance['post_id'], 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID'));
        if (empty($attachments)) {
            return;
        }
        extract($args);
        echo str_replace('well ', '', $before_widget);
        if ($title = get_the_title($instance['post_id'])) {
            echo $before_title . '<a href="' . get_permalink($instance['post_id']) . '" title="' . sprintf(esc_attr__('Permalink to %s', 'the-bootstrap'), strip_tags($title)) . '" rel="bookmark">' . $title . '</a>' . $after_title;
        }
        ?>
		<div id="sidebar-gallery-slider" class="carousel slide">

			<!-- Carousel items -->
			<div class="carousel-inner">
				<?php 
        foreach ($attachments as $attachment) {
            ?>
				<figure class="item">
					<?php 
            echo wp_get_attachment_image($attachment->ID, array(370, 278));
            if (has_excerpt($attachment->ID)) {
                ?>
					<figcaption class="carousel-caption">
						<h4><?php 
                echo get_the_title($attachment->ID);
                ?>
</h4>
						<p><?php 
                echo apply_filters('get_the_excerpt', $attachment->post_excerpt);
                ?>
</p>
					</figcaption>
					<?php 
            }
            ?>
				</figure>
				<?php 
        }
        ?>
			</div><!-- .carousel-inner -->
		
			<!-- Carousel nav -->
			<a class="carousel-control left" href="#sidebar-gallery-slider" data-slide="prev"><?php 
        _ex('&lsaquo;', 'carousel-control', 'the-bootstrap');
        ?>
</a>
			<a class="carousel-control right" href="#sidebar-gallery-slider" data-slide="next"><?php 
        _ex('&rsaquo;', 'carousel-control', 'the-bootstrap');
        ?>
</a>
		</div><!-- #sidebar-gallery-slider .carousel .slide -->
		<?php 
        echo $after_widget;
    }
开发者ID:Covert-Inferno,项目名称:the-bootstrap,代码行数:71,代码来源:the-bootstrap-gallery-widget.php


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