0

Add function to wordpress theme

So I've got this function and i want it to run in a certain moment in page.php, but i don't know where to place it: i've tried going into functions.php doing this: function orario($giorno){ if(get_field($giorno)){ the_field($giorno); } else { echo 'Nessuna Lezione'; } } add_action('init', 'orario'); But the result is the function run at the top of the theme's pages for some reason, and when i call it somewhere else it doesn't work. Any help? Is there another way to do the same thing?

14th Jun 2020, 3:09 PM
Francesco Paolini
Francesco Paolini - avatar
1 Antwort
+ 1
Try finding a different hook. You are using init you should probably find a different hook on wordpress.org that betters suits you're needs
18th Jun 2020, 5:44 PM
Zachiah sawyer
Zachiah sawyer - avatar