enhaced the function to output classes

This commit is contained in:
Jorge vitrubio.net 2024-04-11 13:29:41 +02:00
parent b4222d8506
commit 5f274d8632
1 changed files with 12 additions and 2 deletions

View File

@ -59,11 +59,21 @@ function xarxaprod_plugin_active() {
*/
if ( ! function_exists( 'xarxaprod_class_posttype' ) ):
function xarxaprod_class_posttype (){
if( is_post_type_archive( array('xarxaprod-ajut') ) || is_post_type_archive( array('xarxaprod-convo') ) || is_post_type_archive( array( 'xarxaprod-associat') )) {
if( is_post_type_archive( array('xarxaprod-ajut') ) || is_post_type_archive( array('xarxaprod-convo') ) || is_post_type_archive( array( 'xarxaprod-associat') )) {
//if( get_post_type() == 'xarxaprod-ajut' || get_post_type() == 'xarxaprod-convo' || get_post_type() == 'xarxaprod-associat' ){
echo 'archive-custom-post-type-';
printf (get_post_type_object( get_post_type() )->rewrite['slug']);
}
} elseif( get_post_type() == 'xarxaprod-ajut' || get_post_type() == 'xarxaprod-convo' || get_post_type() == 'xarxaprod-associat' ) {
echo 'custom-post-type-';
printf (get_post_type_object( get_post_type() )->rewrite['slug']);
} else {
$categories = get_the_category();
if ( ! empty( $categories ) ) {
echo 'category-';
echo esc_html( $categories[0]->slug );
}
//printf (get_post_type_object( get_post_type() )->rewrite['slug']);
}
}
endif; //end xarxaprod_calss_posttype