Or, embed this snippet using GenerateWP WordPress Plugin.

Download

Clone

garden shortcode

// Add Shortcode
function garden_news( $atts ) {

	// Attributes
	extract( shortcode_atts(
		array(
			'slug_garden' => '',
		), $atts )
	);

	// Code
// WP_Query arguments
$args = array (
	'category_name'          => 'news',
	'posts_per_page'         => '20',
	'order'                  => 'ASC',
	'orderby'                => 'date',
	
	'tax_query' => array(
			array(
				'taxonomy' => 'garden',
				'field' => 'slug',
				'terms' => $slug_garden
			)
		)





);

// The Query
$query = new WP_Query( $args );

// The Loop
if ( $query->have_posts() ) {
	while ( $query->have_posts() ) {
		$query->the_post();
		// do something
		
		
		$id			= get_the_ID();
		$data 		= get_the_date();
		$titolo 	= get_the_title();
		$abstract	= get_the_excerpt();
		$contenuto	= get_the_content(); 
		$link		= get_the_permalink();
		$thumbnail	= get_the_post_thumbnail(); 
 
		
		echo "<strong>ID</strong> = " . $id . "<br>";
		echo "<strong>DATA</strong> = " . $data . "<br>";
		echo "<strong>TITOLO</strong> = " . $titolo . "<br>";
		echo "<strong>ABSTRACT</strong> = " . $abstract . "<br>";
		echo "<strong>CONTENUTO</strong> = " . $contenuto . "<br>";
		echo "<strong>LINK</strong> = " . $link . "<br>";
		echo "<strong>THUMBNAIL</strong> = " . $thumbnail . "<br>";
		echo "<hr>";

		
		
		




	}
} else {
	// no posts found
}

// Restore original Post Data
wp_reset_postdata();


}
add_shortcode( 'garden_news', 'garden_news' );