Snippets

Crumina Team Custom excerpt

Created by vadimgorlenko last modified
function content( $num, $no_more = false ) {
		global $post;
		$options = get_option( 'second-touch' );


		if ( $options['read_more_style'] == '0' ) {
			$read_more_link = '<a href="' . get_permalink( $post->ID ) . '" class="link-read-more"> </a>';
		} else {
			$read_more_link = '<a href="' . get_permalink( $post->ID ) . '"> ' . __( 'Read more', 'crum' ) . '</a>';
		}
		if ( $no_more == true ) {
			$read_more_link = '';
		}

		$post_excerpt = get_post_field( 'post_excerpt', get_the_ID() );
		if ( isset( $post_excerpt ) && ! ( empty( $post_excerpt ) ) ) {
			$post_content = $post_excerpt;
		} else {
			$post_content = strip_tags( get_post_field( 'post_content', get_the_ID() ) );
		}

		$post_content = strip_shortcodes( $post_content );

		$post_text = mb_substr( $post_content, 0, $num );

		$content = wpautop( $post_text ) . $read_more_link;

		echo $content;
	}

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.