Пример #1
0
 function fourteenxt_excerpts($content = false)
 {
     // If is the home page, an archive, or search results
     if (is_home() || is_archive() && !is_singular()) {
         global $post;
         $content = $post->post_excerpt;
         // If an excerpt is set in the Optional Excerpt box
         if ($content) {
             $content = apply_filters('the_excerpt', $content);
             // If no excerpt is set
         } else {
             $content = $post->post_content;
             if (get_theme_mod('fourteenxt_excerpt_length')) {
                 $excerpt_length = get_theme_mod('fourteenxt_excerpt_length');
             } else {
                 $excerpt_length = 30;
             }
             $words = explode(' ', $content, $excerpt_length + 1);
             $more = fourteenxt_read_more();
             if (count($words) > $excerpt_length) {
                 array_pop($words);
                 array_push($words, $more);
                 $content = implode(' ', $words);
             }
         }
     }
     // Make sure to return the content
     return $content;
 }
Пример #2
0
 function fourteenxt_excerpts($content = false)
 {
     // If is the home page, an archive, or search results
     if (is_home() || is_archive() && !is_singular()) {
         global $post;
         $content = $post->post_excerpt;
         // If an excerpt is set in the Optional Excerpt box
         if ($content) {
             $content = apply_filters('the_excerpt', $content);
             // If no excerpt is set
         } else {
             $content = $post->post_content;
             if (get_theme_mod('fourteenxt_excerpt_length')) {
                 $excerpt_length = get_theme_mod('fourteenxt_excerpt_length');
             } else {
                 $excerpt_length = 30;
             }
             $words = explode(' ', $content, $excerpt_length + 1);
             $more = fourteenxt_read_more();
             if (count($words) > $excerpt_length) {
                 array_pop($words);
                 array_push($words, $more);
                 $content = implode(' ', $words);
             }
             // If post format is video use first video as excerpt
             $postcustom = get_post_custom_keys();
             if ($postcustom) {
                 $i = 1;
                 foreach ($postcustom as $key) {
                     if (strpos($key, 'oembed')) {
                         foreach (get_post_custom_values($key) as $video) {
                             if ($i == 1) {
                                 $content = $video;
                             }
                             $i++;
                         }
                     }
                 }
             }
             $content = $content;
         }
     }
     // Make sure to return the content
     return $content;
 }