WordPress: verificare se un post è di tipo custom nel Loop

Nel Loop è possibile verificare se un post è di tipo custom utilizzando la funzione di WordPress get_post_type(). Vediamo insieme un esempio pratico.

Possiamo utilizzare il seguente codice nel nostro Loop:


if ( 'prodotti' == get_post_type() ) {
           //...
} elseif ( 'portfolio' == get_post_type()) {
           //...
} else {
     //...
}
Torna su