I am having a wordpress widget that contains some html code for a div block. In that div, I have a text ie [year], that I want to replace with <?php echo date("Y"); ?>
. But the problem is that I cannot use str_replace function for that since I have a whole div. So what I am doing is that I am trying to use str_replace but that is not working, Is there any way to do that, my code is as follows:
$date = date("Y");
ob_start();
$uwid = dynamic_sidebar('footer-copyright');
ob_end_clean();
$uwid = str_replace("[year]",$date, $uwid );
echo $uwid
?>
This is not working, but if there is a way to do it with preg_replace, then it would possibly work, but I am not sure about the pattern.