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(); }
/** * 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; }
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; }
/** * 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; }
/** * 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; }
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); }
/** * 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; }
function italystrap_custom_excerpt_more($output) { if (has_excerpt() && !is_attachment()) { $output .= italystrap_read_more_link(); } return $output; }
/** * 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; }
/** * 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; }
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(']]>', ']]>', $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; }
/** * 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 } }
function cosmic_custom_excerpt_more($output) { if (has_excerpt() && !is_attachment()) { $output .= cosmic_reading_link(); } return $output; }
/** * 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; }
/** * 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('‹', 'carousel-control', 'the-bootstrap'); ?> </a> <a class="carousel-control right" href="#sidebar-gallery-slider" data-slide="next"><?php _ex('›', 'carousel-control', 'the-bootstrap'); ?> </a> </div><!-- #sidebar-gallery-slider .carousel .slide --> <?php echo $after_widget; }
/** * @see CPAC_Column::get_value() * @since 2.0 */ public function get_value($post_id) { $value = $this->get_post_excerpt($post_id, $this->options->excerpt_length); if (!has_excerpt($post_id) && $value) { $value = '<span class="cpac-inline-info">' . __('Excerpt from content', 'codepress-admin-columns') . '</span> ' . $value; } return $value; }
function manual_excerpt_more($excerpt) { $excerpt_more = ''; if (has_excerpt()) { $excerpt_more = ' <br/><a href="' . get_permalink() . '" rel="nofollow" class="button">Read more</a>'; } return $excerpt . $excerpt_more; }
/** * Adds new event that send notification to Slack channel * when someone sent message through Contact Form 7. * * @param array $events * @return array * * @filter slack_get_events */ function wp_slack_testimonials_widget_submit($events) { $events['testimonial_published'] = array('action' => 'publish_testimonials-widget', 'description' => __('When a Testimonials is published', 'slack'), 'default' => false, 'message' => function ($ID, $post) { $excerpt = has_excerpt($post->ID) ? apply_filters('get_the_excerpt', $post->post_excerpt) : wp_trim_words(strip_shortcodes($post->post_content), 55, '…'); return sprintf('New testimonial published: *<%1$s|%2$s>* by *%3$s*' . "\n" . '> %4$s', get_permalink($post->ID), get_the_title($post->ID), get_the_author_meta('display_name', $post->post_author), $excerpt); }); return $events; }
function OW_PageExcerpt($params = array()) { extract(shortcode_atts(array('slug' => '', 'imagetop' => false, 'imagefirst' => true, 'imagealt' => '', 'container' => '', 'class' => ''), $params)); $ret = ''; if ($slug == '') { return $ret; } // container if ($class != '' && $container == '') { $container = 'div'; } $cstart = ''; $cend = ''; if ($container) { $cstart = '<' . $container . ($class ? ' class="' . $class . '"' : '') . '>'; $cend = '</' . $container . '>'; } // find page/post from slug $q = new WP_Query("pagename={$slug}"); if (!$q->have_posts()) { $q = new WP_Query("name={$slug}"); } // the loop while ($q->have_posts()) { $q->the_post(); $ispost = has_excerpt(); // link $link = get_permalink(); // title $title = the_title('', '', false); // thumbnail $img = OW_GetThumbnail(); if (!$img) { $img = $imagealt; } // excerpt $ex = ''; if (!$ispost) { $ex = trim(get_post_meta(get_the_ID(), 'description', true)); } if ($ex == '') { $ex = get_the_excerpt(); } $ex = str_replace(array('<br />', ' [...]'), array('', '…'), $ex); // date $date = the_date('', '', '', false); // output if (function_exists('CustomPageExcerpt')) { $ret = CustomPageExcerpt($link, $title, $ex, $img, $date); } else { if ($img) { $img = "<a href=\"{$link}\">{$img}</a>"; } $ret = $cstart . ($imagetop ? $img : '') . '<h2><a href="' . $link . '" title="read the full article">' . $title . "</a></h2>\n" . (!$imagetop && $imagefirst ? $img : '') . ($ispost ? '<p class="info">News article; ' . $date . "</p>\n" : '') . "<p>{$ex} <a href=\"{$link}\" class=\"more\">View »</a></p>\n" . (!$imagetop && !$imagefirst ? $img : '') . $cend; } } return str_replace(BLOGURL, '', $ret); }
/** * If there's a manual excerpt, shove a button link to the * post afterwards * @param $output * @return string */ function peach_excerpt_read_more_link($output) { global $post; if (has_excerpt()) { return $output . bones_excerpt_more(''); } else { return $output; } }
function universal_custom_excerpt_more($output) { if (has_excerpt() && !is_attachment()) { global $id; $output .= ' ' . universal_continue_reading($id); // insert a blank space. } return $output; }
function stormbringer_excerpt_more( $output ) { if ( has_excerpt() && ! is_attachment() ) { $output = '<p class="entry-excerpt">' . $output . stormbringer_more_link() . '</p>'; } else { $output = '<p class="entry-excerpt">' . $output . '</p>'; } return $output; }
/** * Initializes the widget class. * */ public function __construct() { add_filter('the_content', array($this, 'addWidget')); if (has_excerpt()) { add_filter('the_excerpt', array($this, 'addWidget')); } else { add_filter('get_the_excerpt', array($this, 'addWidget')); } }
/** * Remove sharing and likes from custom excerpt. */ function twentysixteen_remove_share() { if (has_excerpt()) { remove_filter('the_excerpt', 'sharing_display', 19); if (class_exists('Jetpack_Likes')) { remove_filter('the_excerpt', array(Jetpack_Likes::init(), 'post_likes'), 30, 1); } } }
/** * Prepare posts * @param WP_REST_Response $response * @param WP_Post $post * @param WP_REST_Request $request * @return WP_REST_Response */ function anunang_api_prepare_post($response, $post, $request) { // add categories $terms = wp_get_post_terms($post->ID, 'category'); $response->data['has_excerpt'] = (bool) has_excerpt($post->ID); foreach ($terms as $term) { $response->data['category'][] = $term; } return $response; }
function custom_columns($column) { switch ($column) { case 'pj_thumb': if (has_post_thumbnail() != '') { echo get_the_post_thumbnail(get_the_ID(), 'thumbnail', array('alt' => cmsms_title(get_the_ID(), false), 'title' => cmsms_title(get_the_ID(), false), 'style' => 'width:75px; height:75px;')); } else { echo '<em>' . __('No Thumbnail', 'cmsmasters') . '</em>'; } break; case 'pj_format': if (get_post_meta(get_the_ID(), 'cmsms_project_format', true) != '') { echo '<p>' . __(ucfirst(get_post_meta(get_the_ID(), 'cmsms_project_format', true)), 'cmsmasters') . '</p>'; } else { echo '<em>' . __('Album', 'cmsmasters') . '</em>'; } break; case 'pj_description': if (has_excerpt() || get_the_content() != '') { theme_excerpt(20); } else { echo '<em>' . __('No Description', 'cmsmasters') . '</em>'; } break; case 'pj_sort_categ': if (get_the_terms(0, 'pj-sort-categs') != '') { $pj_sort_categs = get_the_terms(0, 'pj-sort-categs'); $pj_sort_categs_html = array(); foreach ($pj_sort_categs as $pj_sort_categ) { array_push($pj_sort_categs_html, '<a href="' . get_term_link($pj_sort_categ->slug, 'pj-sort-categs') . '">' . $pj_sort_categ->name . '</a>'); } echo implode($pj_sort_categs_html, ', '); } else { echo '<em>' . __('Uncategorized', 'cmsmasters') . '</em>'; } break; case 'pj_tags': if (get_the_terms(0, 'pj-tags') != '') { $pj_tags = get_the_terms(0, 'pj-tags'); $pj_tag_html = array(); foreach ($pj_tags as $pj_tag) { array_push($pj_tag_html, '<a href="' . get_term_link($pj_tag->slug, 'pj-tags') . '">' . $pj_tag->name . '</a>'); } echo implode($pj_tag_html, ', '); } else { echo '<em>' . __('No Tags', 'cmsmasters') . '</em>'; } break; case 'menu_order': $custom_post = get_post(get_the_ID()); $custom = $custom_post->menu_order; echo $custom; break; } }
public function widget($args, $instance) { // Limit the news items. $num_news = empty($instance['num_news']) ? 3 : $instance['num_news']; // Check if post type exists or not. if (post_type_exists('m1t_banners') && get_theme_mod('show_banners_pt') === true) { global $post; $args = array('post_type' => 'm1t_news', 'orderby' => 'ID', 'order' => 'DESC', 'posts_per_page' => $num_news, 'no_found_rows' => true); $query = new WP_Query($args); } if ($query->posts) { ?> <h2><?php echo $instance['title']; ?> </h2> <ul> <?php foreach ($query->posts as $post) { setup_postdata($post); ?> <li> <h3><a href="<?php the_permalink(); ?> "><?php the_title(); ?> </a></h3> <?php if (has_excerpt(get_the_ID())) { ?> <?php the_excerpt(); ?> <?php } ?> <span class="tweet-time"><?php echo get_the_date('Y-m-d H:i:s'); ?> </span> </li> <?php } wp_reset_postdata(); $query = null; ?> </ul> <?php } else { echo sprintf('<div class="no-data">%s</div>', __('No news posts found', 'mustang')); } }
/** * Output a formatted attachment image. * * @since 1.0.0 * @access public * @return string */ function carelib_get_attachment_image() { if (!wp_attachment_is_image()) { return false; } $image = wp_get_attachment_image(get_the_ID(), 'full', false, array('class' => 'aligncenter')); if (has_excerpt()) { $src = wp_get_attachment_image_src(get_the_ID(), 'full'); $image = img_caption_shortcode(array('align' => 'aligncenter', 'width' => esc_attr($src[1]), 'caption' => get_the_excerpt()), wp_get_attachment_image(get_the_ID(), 'full', false)); } return apply_filters("{$GLOBALS['carelib_prefix']}_carelib_attachment_image", $image); }
/** * Display Attachment Image with caption if available. * @since 0.1.0 */ function tamatebako_attachment_image($mime = '', $file = '') { /* If image has excerpt / caption. */ if (has_excerpt()) { /* Image URL */ $src = wp_get_attachment_image_src(get_the_ID(), 'full'); /* Display image with caption */ return img_caption_shortcode(array('align' => 'aligncenter', 'width' => esc_attr($src[1]), 'caption' => get_the_excerpt()), wp_get_attachment_image(get_the_ID(), 'full', false)); } else { /* Display image without caption. */ return wp_get_attachment_image(get_the_ID(), 'full', false, array('class' => 'aligncenter')); } }
function excerpt_or_content_filter($curr_post) { $format = get_post_format($curr_post['id']); $format = $format ? $format : 'standard'; if ($format == 'standard' || $format == 'gallery' || $format == 'video') { if ($this->display == 'content' && !has_excerpt()) { $curr_post['preview_content'] = get_the_content(__('Read More', 'adap_sc')); } else { $curr_post['preview_content'] = wp_kses_post(get_the_excerpt()); } } return $curr_post; }