How to make an If Else on Excerpt Filter

Here is the solution that seemed to work. Thanks Tom function new_excerpt_more($more) { global $post; $thePostID = $post->ID; if($thePostID == 1128) { return ‘…<a class=”readmore” href=”‘. get_permalink($post->ID) . ‘”>Watch Video &raquo;</a>’; } else { return ‘…<a class=”readmore” href=”‘. get_permalink($post->ID) . ‘”>Read more &raquo;</a>’; } } add_filter(‘excerpt_more’, ‘new_excerpt_more’);

Nothing appears using get_the_excerpt() in category.php

I have checked the code. There are some issues in your code : There is not any method ‘coauthors_posts_links’ but WordPress provides a method the_author_posts_link();. Also for the ‘get_the_post_thumbnail()’ function 2nd parameter must be image size like $thumb = get_the_post_thumbnail($post, ‘thumbnail’,array(‘class’ => ‘front-page-tease-sm’)); I have updated the code. For ‘coauthors_posts_links()’ no idea what you want … Read more

excerpt button not going to custom post page

You to set the global $post, otherwise your get_the_ID() function won’t work because this code is not in a WordPress loop. function all_excerpts_get_more_link($post_excerpt) { global $post; return $post_excerpt . ‘ <p><a class=”btn btn-secondary understrap-read-more-link” href=”‘. get_the_permalink( get_the_ID() ) . ‘”>’ . __(‘VIEW CASE’, ‘understrap’) . ‘</a></p>’; } add_filter(‘wp_trim_excerpt’, ‘all_excerpts_get_more_link’);

Trim excerpt to first paragraph

You can match this with regEx and easily choose the amount of paragraphs to return. // in context function triangle_x_excerpt( $text, $raw_excerpt ) { $content = apply_filters( ‘the_content’, get_the_content() ); $text = ( preg_match( sprintf( ‘~(<p>.+?</p>){%d}~i’, 1 ), $content, $matches ) ) ? $matches[ 0 ] : $content; return preg_replace( “/<img[^>]+\>/i”, “”, $text ); } … Read more

modify text at the bottom of excerpt editor

Try below code. add_filter( ‘gettext’, ‘excerpt_gettext’, 10, 2 ); function excerpt_gettext( $translation, $original ) { $post_type = get_post_type( $_GET[‘post’] ); if($post_type == ‘your custom post type’) { $text = strpos($original, ‘Excerpts are optional hand-crafted summaries of your content that can be used in your theme’); if ($text !== false) { return ‘My Custom Excerpt Discription’; … Read more

Custom excerpt length WooCommerce product

In the end I used substr to deal with the excerpt length inside the slider function. Set is at 140 chars from the beginning. This works quite well: function featured_products_slider() { $args = array( ‘post_type’ => ‘product’, ‘meta_key’ => ‘_featured’, ‘meta_value’ => ‘yes’, ‘post_status’ => ‘publish’ ); $featured = get_posts($args); foreach ($featured as $post) { … Read more

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