How to remove “read more” link from custom post type excerpt

Put the following code in functions.php to show “read more” on all post types except custom_post_type. function excerpt_read_more_link($output) { global $post; if ($post->post_type != ‘custom_post_type’) { $output .= ‘<p><a href=”‘. get_permalink($post->ID) . ‘”>read more</a></p>’; } return $output; } add_filter(‘the_excerpt’, ‘excerpt_read_more_link’);

Only show content before more tag

You can use the WordPress function get_extended to fetch the different parts of a string (the part before and the part after the <!–more–> tag). get_extended returns an array with three keys, of which the keys main and extended are important: $arr[‘main’] contains the part before the more tag, and $arr[‘extended’] the part after the … Read more

How to end the excerpt with a sentence rather than a word?

This requires PHP 5.3+ (WP requires PHP 5.2.4+) add_filter(‘get_the_excerpt’, ‘end_with_sentence’); function end_with_sentence($excerpt) { $allowed_end = array(‘.’, ‘!’, ‘?’, ‘…’); $exc = explode( ‘ ‘, $excerpt ); $found = false; $last=””; while ( ! $found && ! empty($exc) ) { $last = array_pop($exc); $end = strrev( $last ); $found = in_array( $end{0}, $allowed_end ); } return … Read more

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