I'm trying to use functions.php to hide the by-line on posts after a certain date. I'm using the following code but it isn't working. I think it's due to not properly grabbing the post date. How do I get the post date in functions.php?
// 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($postDate > $excludeDate){
echo "<style> .entry-author {display:none !important;} </style>";
}
}
var_dump( $postDate );
tell you? That will let you know if, at least, you've got a valid date string.