I'm a total newbie at PHP/WordPress, so please help me out: I want to add the current calender week (the week number in the year) to my webpage. My idea was to first create a new shortcode in the functions.php file:
function current_week_shortcode() {
return date('W');
}
add_shortcode('current_week', 'current_week_shortcode');
Then I added [current_week] as a new shortcode block to my page. However this doesn't work. Instead it just shows the line, as if its normal text. What did I do wrong? It seems as if WordPress doesn't even recognize it as a short code and therefore doesn't execute it. Did I add the code at the wrong place in the functions.php file? I added it at the end, right above </style> <?php }
Thanks in advance for every advice!
</style> <?php }" - not sure why you would have a<style>element in your functions.php to begin with (someone is doing something really dirty there), but the code to add the shortcode of course needs to go inside of<?php ... ?>tags, not outside.functions.phpscript, or you need to put the function in a child theme instead? Do you have any other custom functions infunctions.phpscript that work?