<?php
$current_user = wp_get_current_user();
if ( is_category( 'Cars' ) && 0 == $current_user->ID ) { ?>
<!-- HTML markup here -->
<?php } else { ?>
<!-- other HTML markup here -->
<?php } ?>
ID will be 0 in the $current_user
object, if the user isn’t logged in.
Related reading:
EDIT
Try using is_user_logged_in()
and in_category()
instead:
<?php
if ( in_category( 'cars' ) && ! is_user_logged_in() ) {
// Current post is in the category 'cars'
// and the current user is NOT logged in;
// do something
} else {
// do something else
}
?>