Implement some shortcode into wp-single.php

Hi there

I would like to customize the wp-single.php to show “recent posts” at the bottom of each existing and new post. In addition I would like to change the post font type.

I tried to implement the following shortcode with an “echo”.

echo do_shortcode(’[recent_posts count=“3”]’);

This does not work

I already copied the wp-single.php into the child theme but don’t know how to customize it.

Any help?

Thanks

Hi There,

In this case, you don’t have to copy the wp-single.php file to your child theme.

You just need to add this code to functions.php file locates in your child theme folder:

add_action( "x_after_the_content_end", "add_post_shortcode" );
function add_post_shortcode() {
	if(is_singular( 'post' )){
		echo do_shortcode( '[recent_posts count="3"]' );
	}
}

Let us know how it goes!

Hi Thai
This works like a charm, but how can I also implement a Titel (Recent post) formated with h1?
And how can I customize the defined font types for Blogposts?

Regards, Ruedi

Hello There,

Thanks for updating in!

If you want to add a title, please have the code updated and use this:

add_action( "x_after_the_content_end", "add_post_shortcode" );
function add_post_shortcode() {
	if(is_singular( 'post' )){
                echo '<h1>Recent Posts</h1>';
		echo do_shortcode( '[recent_posts count="3"]' );
	}
}

And you can customize the font for the blog posts in X > Launch > Options > Typography > Body and Content.

Hope this helps.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.