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


PHP get_the_excerpt函数代码示例

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


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

示例1: hvboom_get_portfolio

function hvboom_get_portfolio()
{
    $portfolio = '<section class="hvboom-portfolio">' . PHP_EOL;
    $args = "post_type=portfolio";
    $catalog = new WP_Query($args);
    while ($catalog->have_posts()) {
        $catalog->the_post();
        $img = hvboom_get_image();
        $portfolio .= '  <article>' . PHP_EOL;
        $portfolio .= '    <div class="styling-wrapper">' . PHP_EOL;
        $portfolio .= $img;
        $portfolio .= '      <header><h1>';
        $portfolio .= sprintf('<a href="%s" rel="bookmark">', esc_url(get_permalink())) . get_the_title() . '</a>';
        $portfolio .= '</h1></header>' . PHP_EOL;
        $portfolio .= '      <section>' . get_the_excerpt() . '</section>' . PHP_EOL;
        $portfolio .= '      <hr />' . PHP_EOL;
        $portfolio .= '      <footer>' . PHP_EOL;
        $portfolio .= sprintf('      <a href="%s" class="" role="button">', esc_url(get_permalink())) . __('View Project', 'hvboom') . '</a>' . PHP_EOL;
        $portfolio .= '      </footer>' . PHP_EOL;
        $portfolio .= '    </div> <!-- end of styling-wrapper -->' . PHP_EOL;
        $portfolio .= '  </article>' . PHP_EOL;
        $portfolio .= '  <smart-break></smart-break> <!-- styling element used only to break article in a responsive way -->' . PHP_EOL;
    }
    wp_reset_postdata();
    $portfolio .= '</section>' . PHP_EOL;
    return $portfolio;
}
开发者ID:HVboom,项目名称:hvboom-portfolio,代码行数:27,代码来源:hvboom-portfolio-cpt.php

示例2: getRecent

 /**
  * Latest blog posts
  *
  * @param int    $limit post display limit
  *
  * @param string $thumbnail_size
  *
  * @return array
  */
 public static function getRecent($limit = 10, $thumbnail_size = 'thumbnail')
 {
     $args = array('numberposts' => $limit, 'offset' => 0, 'category' => 0, 'orderby' => 'post_date', 'order' => 'DESC', 'include' => '', 'exclude' => '', 'meta_key' => '', 'meta_value' => '', 'post_type' => 'post', 'post_status' => 'draft, publish, future, pending', 'suppress_filters' => true);
     $array_out = array();
     $recent_posts = \get_posts(\wp_parse_args($args));
     /*$like_bool    = Option::get_theme_option( 'blog_list_like' );
       if ( $like_bool === '1' ) {
           $PostLike = \SilverWp\Ajax\PostLike::getInstance();
       }*/
     foreach ($recent_posts as $key => $recent) {
         \setup_postdata($recent);
         $post_id = $recent->ID;
         //$array_out[ $key ] = $recent;
         $array_out[$key]['ID'] = $post_id;
         $array_out[$key]['post_title'] = \get_the_title($post_id);
         $array_out[$key]['url'] = \get_the_permalink($post_id);
         $array_out[$key]['post_author'] = \get_the_author();
         $array_out[$key]['post_date'] = \get_the_date('', $post_id);
         $array_out[$key]['post_date_utc'] = \get_the_time('c', $post_id);
         //$array_out[ $key ]['post_like'] = ($like_bool === '1') ? $PostLike->getPostLikeCount($post_id) : '';
         $array_out[$key]['post_comment_count'] = $recent->comment_count;
         if (strpos($recent->post_content, '<!--more-->') || empty($recent->post_excerpt)) {
             $array_out[$key]['post_excerpt'] = \get_the_excerpt();
         } else {
             $array_out[$key]['post_excerpt'] = $recent->post_excerpt;
         }
         $array_out[$key]['image_html'] = \get_the_post_thumbnail($post_id, $thumbnail_size);
         // Thumbnail
         $array_out[$key]['categories'] = self::getTaxonomy($post_id);
     }
     \wp_reset_postdata();
     return $array_out;
 }
开发者ID:silversite,项目名称:silverwp,代码行数:42,代码来源:Post.php

示例3: blog_summary_shortcode

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;
}
开发者ID:Turante,项目名称:wp-plugin-dev,代码行数:60,代码来源:blog-summary.php

示例4: 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

示例5: cfct_about_text

function cfct_about_text()
{
    $about_text = get_option('cfct_about_text');
    if (!empty($about_text)) {
        $about_text = cfct_basic_content_formatting($about_text);
    } else {
        global $post, $wp_query;
        $orig_post = $post;
        isset($wp_query->query_vars['page']) ? $page = $wp_query->query_vars['page'] : ($page = null);
        // temporary - resetting below
        $wp_query->query_vars['page'] = null;
        remove_filter('the_excerpt', 'st_add_widget');
        $about_query = new WP_Query('pagename=about');
        while ($about_query->have_posts()) {
            $about_query->the_post();
            $about_text = get_the_excerpt() . sprintf(__('<a class="more" href="%s">more &rarr;</a>', 'carrington'), get_permalink());
        }
        $wp_query->query_vars['page'] = $page;
        $post = $orig_post;
        setup_postdata($post);
    }
    if (function_exists('st_add_widget')) {
        add_filter('the_excerpt', 'st_add_widget');
    }
    return $about_text;
}
开发者ID:Linuxwang,项目名称:PIE,代码行数:26,代码来源:carrington.php

示例6: todays_movies

function todays_movies()
{
    $todays_movies = array();
    $args = array('post_type' => array('film'), 'posts_per_page' => -1);
    $query = new WP_Query($args);
    if ($query->have_posts()) {
        while ($query->have_posts()) {
            $query->the_post();
            $schedule = get_post_meta(get_the_ID(), 'film_horaire', true);
            $duration = get_post_meta(get_the_ID(), 'film_duration', true);
            //the_title();
            //piklist::pre($schedule);
            foreach ($schedule as $key) {
                //echo $key['film_date'] . '<br>';
                $movie_iso_date = DateTime::createFromFormat('d/m/Y', $key['film_date'])->format('Y-m-d');
                //echo $movie_iso_date . '<br>';
                if (date('Y-m-d') == $movie_iso_date) {
                    $director = get_the_terms($post->ID, 'director');
                    $countries = get_the_terms($post->ID, 'country');
                    $languages = get_the_terms($post->ID, 'language');
                    $year = get_the_terms($post->ID, 'film-year');
                    $format = get_the_terms($post->ID, 'format');
                    $featured_image = wp_get_attachment_url(get_post_thumbnail_id(get_the_ID()));
                    $film_detail = array('id' => get_the_ID(), 'image' => $featured_image, 'title' => get_the_title(), 'duration' => $duration, 'excerpt' => get_the_excerpt(), 'link' => get_permalink(), 'date' => $movie_iso_date, 'hour' => $key['film_heure'], 'director' => $director, 'country' => $countries, 'language' => $languages, 'year' => $year, 'format' => $format);
                    array_push($todays_movies, $film_detail);
                }
            }
        }
        wp_reset_postdata();
    }
    return $todays_movies;
}
开发者ID:gabzon,项目名称:spoutnik,代码行数:32,代码来源:sorting.php

示例7: description

function description()
{
    if (is_home() || is_front_page()) {
        echo trim(of_get_option('site_description'));
    } elseif (is_category()) {
        $description = strip_tags(category_description());
        echo trim($description);
    } elseif (is_single()) {
        if (get_the_excerpt()) {
            echo get_the_excerpt();
        } else {
            global $post;
            $description = trim(str_replace(array("\r\n", "\r", "\n", " ", " "), " ", str_replace("\"", "'", strip_tags($post->post_content))));
            echo mb_substr($description, 0, 220, 'utf-8');
        }
    } elseif (is_search()) {
        echo '“';
        the_search_query();
        echo '”为您找到结果 ';
        global $wp_query;
        echo $wp_query->found_posts;
        echo ' 个';
    } elseif (is_tag()) {
        $description = strip_tags(tag_description());
        echo trim($description);
    } else {
        $description = strip_tags(term_description());
        echo trim($description);
    }
}
开发者ID:carpliyz,项目名称:9IPHP,代码行数:30,代码来源:header.php

示例8: get_skills_registration

function get_skills_registration($atts)
{
    $string = '';
    //$attributes = shortcode_atts( array(), $atts ); //get attributes
    $args = array('posts_per_page' => -1, 'post_type' => 'skeleton_skill', 'orderby' => 'menu_order', 'order' => 'ASC');
    $skills = get_posts($args);
    global $post;
    $string .= "<h3 class='shortcode-title'>Skills</h3>";
    $i = 0;
    foreach ($skills as $post) {
        $i++;
        if ($i % 2 == 0) {
            $class = 'right';
        } else {
            $class = 'left';
        }
        setup_postdata($post);
        $bg_image_url = '"' . wp_get_attachment_url(get_post_thumbnail_id($post->ID), 'full') . '"';
        $content = get_the_excerpt();
        $title = get_the_title();
        $link = get_the_permalink();
        $string .= "<div class='skill-container' style='background-image: url({$bg_image_url})'>";
        $string .= "<a class='skill-link' href='{$link}' title='{$title}'></a>";
        $string .= "<div class='skill-content {$class}'>";
        $string .= "<h4>{$title}</h4>";
        $string .= "<div class='description'>{$content}</div>";
        $string .= "</div>";
        //skill-content
        $string .= "</div>";
        //skill-container
    }
    wp_reset_query();
    return $string;
}
开发者ID:adamgiese,项目名称:portfoliage-theme,代码行数:34,代码来源:skills.php

示例9: arras_get_thumbnail

/**
 * Helper function to grab and display thumbnail from specified post
 * @since 1.4.0
 */
function arras_get_thumbnail($size = 'thumbnail', $id = NULL)
{
    global $post, $arras_image_sizes;
    $empty_thumbnail = '<img src="' . get_template_directory_uri() . '/images/thumbnail.png" alt="' . get_the_excerpt() . '" title="' . get_the_title() . '" />';
    if ($post) {
        $id = $post->ID;
    }
    // get post thumbnail (WordPress 2.9)
    if (function_exists('has_post_thumbnail')) {
        if (has_post_thumbnail($id)) {
            return get_the_post_thumbnail($id, $size, array('alt' => get_the_excerpt(), 'title' => get_the_title()));
        } else {
            // Could it be an attachment?
            if ($post->post_type == 'attachment') {
                return wp_get_attachment_image($id, $size, false, array('alt' => get_the_excerpt(), 'title' => get_the_title()));
            }
            // Use first thumbnail if auto thumbs is enabled.
            if (arras_get_option('auto_thumbs')) {
                $img_id = arras_get_first_post_image_id();
                if (!$img_id) {
                    return $empty_thumbnail;
                }
                return wp_get_attachment_image($img_id, $size, false, array('alt' => get_the_excerpt(), 'title' => get_the_title()));
            }
        }
    }
    return $empty_thumbnail;
}
开发者ID:rosshettel,项目名称:Northern-Star-Blogs,代码行数:32,代码来源:thumbnails.php

示例10: ipin_opengraph

function ipin_opengraph()
{
    if (is_single()) {
        global $post;
        setup_postdata($post);
        $output = '<meta property="og:type" content="article" />' . "\n";
        $output .= '<meta property="og:title" content="' . preg_replace('/[\\n\\r]/', ' ', the_title_attribute('echo=0')) . '" />' . "\n";
        $output .= '<meta property="og:url" content="' . get_permalink() . '" />' . "\n";
        $output .= '<meta property="og:description" content="' . esc_attr(get_the_excerpt()) . '" />' . "\n";
        if (has_post_thumbnail()) {
            $imgsrc = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'large');
            $output .= '<meta property="og:image" content="' . $imgsrc[0] . '" />' . "\n";
        }
        echo $output;
    }
    if (is_tax('board')) {
        global $post, $wp_query;
        setup_postdata($post);
        $output = '<meta property="og:type" content="article" />' . "\n";
        $output .= '<meta property="og:title" content="' . $wp_query->queried_object->name . '" />' . "\n";
        $output .= '<meta property="og:url" content="' . home_url('/board/') . $wp_query->queried_object->term_id . '/" />' . "\n";
        $output .= '<meta property="og:description" content="" />' . "\n";
        if (has_post_thumbnail()) {
            $imgsrc = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'large');
            $output .= '<meta property="og:image" content="' . $imgsrc[0] . '" />' . "\n";
        }
        echo $output;
    }
}
开发者ID:evinw,项目名称:project_modelv,代码行数:29,代码来源:functions.php

示例11: register_meta_tags

 public function register_meta_tags()
 {
     add_action('wp_head', function () {
         if (is_singular() && false == post_password_required()) {
             if ('' == ($description = get_the_excerpt())) {
                 $description = wp_trim_words(esc_html(strip_shortcodes(get_the_content())), 20, '...');
             }
         } elseif (is_category() && '' != category_description()) {
             $description = category_description();
         } elseif (is_tag() && '' != term_description()) {
             $description = term_description();
         } else {
             $description = get_bloginfo('description');
         }
         $description = esc_attr($description);
         echo "<meta name=\"description\" content=\"{$description}\" />\n";
         echo "<meta name=\"og:description\" content=\"{$description}\" />\n";
         if (is_singular() && false == post_password_required() && has_post_thumbnail()) {
             list($image, $width, $height) = wp_get_attachment_image_src(get_post_thumbnail_id(), 'facebook');
         } else {
             $image = apply_filters('', $this->get_theme_assets_url() . '/images/logo-fb.png');
         }
         $image = esc_url($image);
         echo "<meta name=\"og:image\" content=\"{$image}\" />\n";
         echo "<meta name=\"twitter:image\" content=\"{$image}\" />\n";
     });
 }
开发者ID:shtrihstr,项目名称:wpk15-theme-wpkit,代码行数:27,代码来源:Initialization.php

示例12: find_post

 function find_post()
 {
     $this->verify_ajax_call();
     $q = $_GET['query'];
     $the_query = new WP_Query('s=' . $q);
     //$response = array('empty','test');
     $d = new stdClass();
     $d->query = $q;
     $d->suggestions = array();
     $d->data = array();
     // The Loop
     global $post;
     while ($the_query->have_posts()) {
         $the_query->the_post();
         $d->suggestions[] = get_the_title();
         $content = get_the_content();
         $content = apply_filters('the_content', $content);
         $content = str_replace(']]>', ']]&gt;', $content);
         $d->data[] = array("content" => $content, "excerpt" => get_the_excerpt(), "url" => get_permalink());
     }
     // Reset Post Data
     wp_reset_postdata();
     // Serialize the response back as JSON
     echo json_encode($d);
     die;
 }
开发者ID:richardsweeney,项目名称:sendpress,代码行数:26,代码来源:class-sendpress-ajax-loader.php

示例13: sequence_slider_display

function sequence_slider_display($atts)
{
    extract(shortcode_atts(array('limit' => 10), $atts));
    $args = array('post_type' => 'sequence-slider', 'posts_per_page' => $limit);
    // The Query
    $the_query = new WP_Query($args);
    $html = null;
    // The Loop
    if ($the_query->have_posts()) {
        $html .= '<div class="sequence-theme">';
        $html .= '<div class="sequence">';
        $html .= '<img class="sequence-prev" src="' . SEQUENCE_PLUGIN_URL . 'images/bt-prev.png" alt="Previous Frame" />';
        $html .= '<img class="sequence-next" src="' . SEQUENCE_PLUGIN_URL . 'images/bt-next.png" alt="Next Frame" />';
        $html .= '<ul class="sequence-canvas">';
        while ($the_query->have_posts()) {
            $the_query->the_post();
            //echo "<pre>";
            //print_r($the_query);
            $html .= '<li class="animate-in">';
            $html .= '<h3 class="title">' . get_the_title() . '</h3>';
            $html .= '<h4 class="subtitle">' . get_the_excerpt() . '';
            $html .= '<a class="slider_link" href="' . get_post_meta($the_query->post->ID, '_link', true) . '">' . get_post_meta($the_query->post->ID, '_text', true) . '</a></h4>';
            $html .= get_the_post_thumbnail($the_query->post->ID, 'full', array('class' => 'model'));
            $html .= '</li>';
        }
        $html .= '</ul>';
        //$html .= '<ul class="sequence-pagination"></ul>';
        $html .= '</div></div>';
    } else {
        // no posts found
    }
    /* Restore original Post Data */
    wp_reset_postdata();
    return $html;
}
开发者ID:azeemgolive,项目名称:thefunkidsgame,代码行数:35,代码来源:functions.php

示例14: queryAndResponse

 protected function queryAndResponse($arg)
 {
     $the_query = new WP_Query($arg);
     if ($the_query->have_posts()) {
         $counter = 0;
         $items = array();
         while ($the_query->have_posts()) {
             $the_query->the_post();
             global $post;
             $title = get_the_title();
             $link = get_permalink();
             $excerpt = wechat_get_excerpt(get_the_excerpt());
             if ($counter == 0) {
                 $thumb = wechat_get_thumb($post, array(640, 320));
             } else {
                 $thumb = wechat_get_thumb($post, array(80, 80));
             }
             $new_item = new NewsResponseItem($title, $excerpt, $thumb, $link);
             array_push($items, $new_item);
             // 最多显示3篇
             if (++$counter == 3) {
                 break;
             }
         }
         $this->responseNews($items);
     } else {
         $this->responseText("不好意思~没有找到您想要的东东~请换个关键字再试试?");
     }
     wp_reset_postdata();
 }
开发者ID:qinzhe,项目名称:wechat-robot,代码行数:30,代码来源:wechat-robot.php

示例15: slickc_load_images

function slickc_load_images($attributes)
{
    $args = array('post_type' => 'slickc', 'posts_per_page' => '-1', 'orderby' => $attributes['orderby'], 'order' => $attributes['order']);
    if (!empty($attributes['category'])) {
        $args['carousel_category'] = $attributes['category'];
    }
    if (!empty($attributes['id'])) {
        $args['p'] = $attributes['id'];
    }
    $loop = new WP_Query($args);
    $images = array();
    $output = '';
    while ($loop->have_posts()) {
        $loop->the_post();
        $image = get_the_post_thumbnail(get_the_ID(), 'full');
        if (!empty($image)) {
            $post_id = get_the_ID();
            $title = get_the_title();
            $content = get_the_excerpt();
            $image_src = wp_get_attachment_image_src(get_post_thumbnail_id(), 'full');
            $image_src = $image_src[0];
            $url = get_post_meta(get_the_ID(), 'slickc_image_url');
            $url_openblank = get_post_meta(get_the_ID(), 'slickc_image_url_openblank');
            $images[] = array('post_id' => $post_id, 'title' => $title, 'content' => $content, 'image' => $image, 'img_src' => $image_src, 'url' => esc_url($url[0]), 'open_blank' => $url_openblank[0]);
        }
    }
    return $images;
}
开发者ID:jgacuca567,项目名称:bethel,代码行数:28,代码来源:slick-frontend.php


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