Pawan Kumawat

How To Customize/Replace WordPress Post Excerpts

Example: Sometime we need to show content on frontend with adding some prefix or suffix or may be you have enter spelling mistakes in 2000 posts. so it is very difficult to modify 2000 posts so we can modify using filter . SO mistake will be replaced by correction.

 

For Modifying post content only:

 

function link_words( $text ) {
   $replace = 'Replace with';
   $text = str_replace( 'Want To replace text', $replace, $text );
   return $text;
}
add_filter( 'the_content', 'link_words' );

 

For Modifying post excerpt only

 

function link_words( $text ) {
   $replace = 'Replace with';
   $text = str_replace( 'Want To replace text', $replace, $text );
   return $text;
}
add_filter( 'the_excerpt', 'link_words' );

 

For Modifying post content and excerpt both

 

function link_words( $text ) {
   $replace = 'Replace with';
   $text = str_replace( 'Want To replace text', $replace, $text );
   return $text;
}
add_filter( 'the_content', 'link_words' );
add_filter( 'the_excerpt', 'link_words' );

 

Categories

Related Blogs

Shortcodes included with Dokan

Dokan is a popular multi-vendor marketplace plugin for WooCommerce that allows you to create and manage a marketplace where multiple vendors can sell their products. Dokan provides several shortcodes that you can use to display various elements and functionalities on your marketplace pages. Here are some of the essential shortcodes provided by Dokan:

Ajax Add to Cart Quantity on Shop WooCommerce

To enable AJAX add to cart with quantity selectors on the WooCommerce shop page, you’ll need to use JavaScript to handle the AJAX request and update the cart quantity dynamically. Below are the steps to achieve this:

How To Add Sub Menu In WordPress Admin Panel

How to add sub-menu in WordPress admin panel – In this post we see how we can add custom sub-menu to admin sidebar. Sometimes when we on WordPress and we need to show some features or any information in admin page then we can use this code snippet to create the same.