Click to copy

Paste to your functions.php file

 * Creates the [post_excerpt] shortcode that will display a single
 * post by its ID by running a custom Loop. Shortcode displays post
 * title, excerpt, and featured image.
 * @since 1.0

function md_post_excerpt( $atts, $content = '' ) {
	extract( shortcode_atts( array(
		'id'    => '',
		'title' => '',
		'desc'  => ''
	), $atts, 'post_excerpt' ) );
	if ( empty( $atts['id'] ) ) return;
	$loop = new WP_Query( array(
		'post_type' => 'post',
		'p'         => $atts['id']
	) );
	<?php if ( $loop->have_posts() ) : ?>
		<?php while ( $loop->have_posts() ) : $loop->the_post();
			$title = ! empty( $atts['title'] ) ? $atts['title'] : get_the_title();
			$desc  = ! empty( $atts['desc'] ) ? $atts['desc'] : get_the_excerpt();
			<div class="embed-excerpt block-single mb-single">
				<div class="columns-30-70 columns-single">
					<div class="col col1 mb-half text-center">
					    <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail( 'medium' ); ?></a>
					<div class="col col2">
					    <h5><a href="<?php the_permalink(); ?>"><?php echo $title; ?></a></h5>
					    <p><?php echo $desc; ?></p>
					    <span class="links-sec"><a href="<?php the_permalink(); ?>"><?php _e( 'Read more →', 'md' ); ?></a></span>
		<?php endwhile; ?>
		<?php wp_reset_postdata(); ?>
	<?php endif; ?>
	return ob_get_clean();
add_shortcode( 'post_excerpt', 'md_post_excerpt' );
Click to copy

Use the shortcode anywhere on your site:

[post_excerpt id="post_id" title="My Custom Title" desc="My custom description"]	
Click to copy
Click to copy

Optional, a way to add a shadow around the excerpt.

.embed-excerpt {
	box-shadow: 0 7px 20px rgba(0, 0, 0, 0.12);
Click to copy
Embeddable Post Excerpt

Embedded Post Excerpts

With this custom shortcode you can quickly embed posts excerpts around your site! Great editorial tool for online magazines, review sites, or for any time you want to mention another post in your writing.

Shortcode Usage

After installing the shortcode (follow steps 1 + 2 below) you can execute it anywhere WordPress accepts shortcodes. To connect to a post, you simply need to enter the post ID you wish to display:

[post_excerpt id="post_id"]

Tip: you can quickly get the ID of a post by editing it and searching the URL to grab the ID (screenshot below):

Get WordPress Post ID

MD Update in Progress

The new private MD account area is currently being rolled out—follow the beacon to login and see what's new!


Get the latest MD sent straight to your inbox

There's always something new in the works in the MD Labs! Join the email list to get the newest content and releases sent straight to your inbox.*

Join the MD Newsletter

* I only email you when there's something new, or to share an exciting MD sneak peak.