
Untitled
By: a guest on
Aug 8th, 2012 | syntax:
None | size: 0.65 KB | hits: 11 | expires: Never
Conditional Tags for Custom Taxonomy in Custom Post Type
<?php if (has_custax('a-custax')) {
echo 'do something A';
} else {
echo 'do something B';
}
<?php function has_custax( $custax, $_post = null ) {
if ( empty( $custax ) )
return false;
if ( $_post )
$_post = get_post( $_post );
else
$_post =& $GLOBALS['post'];
if ( !$_post )
return false;
$r = is_object_in_term( $_post->ID, 'custax', $custax );
if ( is_wp_error( $r ) )
return false;
return $r;
}
?>
<?php if ( has_custax( 'a-custax', $post->ID ) ) {
echo 'do something A';
} else { echo 'do something B'; }; ?>