Replace -tag in the_excerpt

You should try this: function replace_tag($string){ $search = array(‘<p>’, ‘</p>’); $replace = array(‘<h2>’, ‘</h2>’); echo str_replace($search, $replace, $string); return $string; } add_filter(‘the_excerpt’, ‘replace_tag’); or this: function replace_tag($string){ $replace = array( ‘<p>’ => ‘<h2>’, ‘</p>’ => ‘</h2>’ ); $string = str_replace(array_keys($replace), $replace, $string); return $string; } add_filter(‘the_excerpt’, ‘replace_tag’);

Create different flavours of excerpt

Probably it’s not the best approach because it requires introducing a global variable but here’s the idea: In Posts_in_Page plugin there are 2 filters, one is fired before output of these items posts_in_page_pre_loop, and one after output end posts_in_page_post_loop. So the plan is to create global variable which will be set to true when you … Read more

Default excerpt for parent of a custom post type

This will default the excerpt value in your custom post type only for new posts: add_filter( ‘default_excerpt’, ‘smyles_default_custom_post_excerpt’, 10, 2 ); /** * Default Excerpt for Custom Post Type * * @param string $post_excerpt Default post excerpt. * @param WP_Post $post Post object. * * @return string * */ function smyles_default_custom_post_excerpt( $post_excerpt, $post ){ if( … Read more

How to limit wordpress the_excerpt() dynamically

according to the documentation, it is more correct to change the length of the excerpt using add_filter: add_filter( ‘excerpt_length’, function(){ return 10; }); you can make your own function based on this, like this: add_filter( ‘excerpt_length’, ‘new_excerpt’, 10, 1); function new_excerpt( $lenth ){ return $length; }); … apply_filters( ‘excerpt_length’, 150 );

Get the automatic excerpt from a page created with gutenberg

You can hook the get_the_excerpt filter with parse_blocks to extract the content of your post. add_filter( ‘get_the_excerpt’, ‘se378694_default_excerpt’, 10, 2 ); function se378694_default_excerpt( string $post_excerpt, WP_Post $post ):string { if ( empty( $post_excerpt ) ) { $blocks = parse_blocks( $post->post_content ); // check if the first block matches the type of content you want for … Read more

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