Shortcode per visualizzare gli ultimi post di due categorie

  • Avatar di Sconosciuto

    Ciao a tutti,

    ho l’esigenza di creare uno shortcode per visualizzare gli ultimi 5 post che appartengono a entrambi due categorie.

    Ho provato con questo:

    function latest-news-render( $atts ) {
    	$html = "";
    	query_posts(array('category__and'=>array(2,6),'showposts'=>5,'orderby'=>date,'order'=>DESC));
    	if ( have_posts() ) : while ( have_posts() ) : the_post();
    		$html .= "<h2>" . get_the_title() . " </h2>";
    		$html .= "<p>" . get_the_excerpt() . "</p>";
    		$html .= "<a href="" . get_permalink() . "" class="button">Read more</a>";
    	endwhile;
        wp_reset_postdata();
    	endif;
    	return $html;
    }
    add_shortcode("latest-news", "latest-news-render");

    Ma non appena salvo il file functions.php del tema dove inserisco questo codice, mi crasha tutto il sito diventando non raggiungibile…

    Dove sbaglio?
    Grazie.

  • L'argomento ‘Shortcode per visualizzare gli ultimi post di due categorie’ è chiuso a nuove risposte.