Get excerpt from $post->post_content

When in the loop, this will produce excerpt from $post->post_content directly: <?php echo wp_trim_excerpt(); ?> Read more HERE. Alternative Solution: If you are not in the loop, then, you may use similar implementation as done in the wp_trim_excerpt function: $text = strip_shortcodes( $post->post_content ); $text = apply_filters( ‘the_content’, $text ); $text = str_replace(‘]]>’, ‘]]&gt;’, $text); … Read more

Remove Ellipses from Excerpt

You haven’t added the second filter, at least not in the code posted. If used, that filter will not print ellipses. // Changing excerpt more function new_excerpt_more($more) { global $post; remove_filter(‘excerpt_more’, ‘new_excerpt_more’); return ‘ <a class=”read_more” href=”‘. get_permalink($post->ID) . ‘”>’ . ‘read more’ . ‘</a>’; } add_filter(‘excerpt_more’,’new_excerpt_more’); Notice the couple of changes I made to … Read more

Modify ‘Read more’ link adding a new class

What (exactly) happens When calling the_content() inside your template, you are able to call it without any parameters. This means, that the function already has the defaults of null for both arguments: The “more” link text and the boolean switch that allows you to strip teaser content before the “more” link text. The the_content() function … Read more

How do I filter the excerpt metabox description in admin?

This description is generated by post_excerpt_meta_box() function and is not passed through any explicit filters. It is however echoed by translation-related _e() function and so passes through gettext filter (which from your question you are already familiar with). As for limiting it to your CPT, I think current post type in admin is held in … Read more

Mandatory excerpt for custom post type

The code adds a filter to wp_insert_post_data: add_filter(‘wp_insert_post_data’, ‘mandatory_excerpt’); And here’s the callback: function mandatory_excerpt($data) { $excerpt = $data[‘post_excerpt’]; if (empty($excerpt)) { if ($data[‘post_status’] === ‘publish’) { add_filter(‘redirect_post_location’, ‘excerpt_error_message_redirect’, ’99’); } $data[‘post_status’] = ‘draft’; } return $data; } The filter callback is passed $data, which as per the Codex includes the following post data: ‘post_author’, … Read more

excerpt in characters

I used this code in one of my last projects: function ng_get_excerpt( $count ){ $permalink = get_permalink( $post->ID ); $excerpt = get_the_content(); $excerpt = strip_tags( $excerpt ); $excerpt = mb_substr( $excerpt, 0, $count ); $excerpt = mb_substr( $excerpt, 0, strripos( $excerpt, ” ” ) ); $excerpt = rtrim( $excerpt, “,.;:- _!$&#” ); $excerpt = $excerpt … Read more

Display Links in Excerpts?

You can use the script I found here: http://aaronrussell.co.uk/legacy/improving-wordpress-the_excerpt/ I’ve modified it to show links in the excerpt, and removed some of the other functions: <?php function keep_my_links($text) { global $post; if ( ” == $text ) { $text = get_the_content(”); $text = apply_filters(‘the_content’, $text); $text = str_replace(‘\]\]\>’, ‘]]&gt;’, $text); $text = preg_replace(‘@<script[^>]*?>.*?</script>@si’, ”, $text); … Read more

Customizing get_the_excerpt() to specific length and “Read More” output.

To get a specific length you can use: wp_trim_words function. It has 3 parameters. Text to trim. Ex: get_the_content() Number of words. Ex: 295 What to append after end of the text. Ex: ” This means null. Use this: <span> <?php echo wp_trim_words( get_the_content(), 295, ” ); ?> <i><a style=”color:#1975D1;float:Right;” class=”title” href=”https://wordpress.stackexchange.com/questions/75069/<?php the_permalink() ?>” rel=”bookmark”>Click … Read more

Remove “Continue Reading” Link From the Teaser Excerpt Only

Change standard text for all excerpts: function custom_excerpt_more($more) { global $post; $more_text=”…”; return ‘… <a href=”‘. get_permalink($post->ID) . ‘”>’ . $more_text . ‘</a>’; } add_filter(‘excerpt_more’, ‘custom_excerpt_more’); Create your own excerpt function: // Rafael Marques Excerpt Function 😉 function rm_excerpt($limit = null, $separator = null) { // Set standard words limit if (is_null($limit)){ $excerpt = explode(‘ … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)