How to display recent articles automatically?

Hi team,

We are using Ess. Grid to display our recent articles at the bottom of each post.

To do so, we have to add a shortcode at the end of each post and we wonder if there is something we could do to display the recent articles automatically.

Also, we were trying to add the PHP code to display the Social Media Sharing Icons, but the icons appear under the recent articles and we need them to appear above.

Any solution? We always appreciate your help.

Many thanks in advance!

Hi There,

It’s possible with the custom PHP. I could see that you’ve already setup a child theme.

Please update your PHP code to display the social media sharing to this code:

function x_add_social_sharing() {
	echo do_shortcode('[x_share title="Share this Post" facebook="true" twitter="true" google_plus="true" linkedin="true" pinterest="true" reddit="true" email="true"]');
	echo do_shortcode( '[ess_grid alias="products"]' );
}
add_action('x_before_the_content_end', 'x_add_social_sharing');

Don’t forget to replace the [ess_grid alias="products"] shortcode with yours.

Hope it helps :slight_smile:

Hi @thai,

It works, but…

We don’t want it to appear in this main page: http://www.lbcabarete.com/lb-blog/

Only in the post pages, example: http://www.lbcabarete.com/blog/why-cabarete/

Any solution?

Hi There,

To display it on the single post only, please update the code to this:

function x_add_social_sharing() {
	if(is_singular( 'post' )){
		echo do_shortcode('[x_share title="Share this Post" facebook="true" twitter="true" google_plus="true" linkedin="true" pinterest="true" reddit="true" email="true"]');
		echo do_shortcode( '[ess_grid alias="products"]' );
	}
}
add_action('x_before_the_content_end', 'x_add_social_sharing');

Hope it helps :slight_smile:

Perfect! It works now.

Thank you very much, @thai!

You are most welcome. :slight_smile:

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