It’s probably getting the date as you expect, but the >
is essentially a mathematical operator and you’re trying to use it to compare two strings.
You can use strtotime()
to convert the dates to integers (# of seconds elapsed since 1970-01-01
), and compare those.
// Hide By-Line
add_action('wp_head','my_head_css');
function my_head_css(){
$excludeDate = date("2021-06-02");
$postDate = get_the_date('Y-m-d');
if( strtotime( $postDate ) > strtotime( $excludeDate ) ){
echo "<style> .entry-author {display:none !important;} </style>";
}
}