Verificare se ci troviamo nel template di un singolo custom post type in WordPress

Verificare se ci troviamo nel template di un singolo custom post type in WordPress

I custom post type di norma hanno sempre un template chiamato single-nome.php dove nome è il nome abbreviato del custom post type. Possiamo verificare se stiamo visualizzando un singolo custom post type con molta facilità.

Utilizziamo la funzione is_singular():


if( is_singular( 'prodotti' ) ) {
	// Stiamo visualizzando il singolo post del custom post type 'prodotti'
}

Torna su