How can you test a WordPress copyright year that is generated dynamically or through PHP, meaning when the year changes without waiting an entire year to see if it changes? I do not know anything about virtual containers or anything like that, so try to go easy on me here. If that's what it requires then show me in a simple way how I can test this.
I had bought a WordPress theme that did not come with a copyright year that would auto update. So I asked the developer for a script that would do so and placed it in the functions.php file in my child theme folder. So when the year changed from 2019 to 2020 the year did not flip over.
Here is the original code given to me.
function child_theme_footer_text() {
echo get_the_date( 'Y' );
}
add_action( 'gridbox_footer_text', 'child_theme_footer_text' );
It did not work. I then changed the code from that to this :
function child_theme_footer_text() {
echo date( "Y" );
}
add_action( 'gridbox_footer_text', 'child_theme_footer_text' );
As you can see I changed echo get_the_date( ‘Y’ );
to echo date( “Y”);
I also changed the single quotes to double quotes around the Y
. This changed the date but it could have changed just as easily by simply removing and then placing back the original code and I would still never know if it is actually working or not.
I do not think that changing the echo get_the_date( ‘Y’ );
to echo date( “Y”);
actually did anything at all and I only thought it did. I think that just reset it as if I was inserting the code for the very first time.
Also, the actual file name in the folder of my WP child theme is named gridbox-child. I asked the developer if I was supposed to change the name or slug from child_theme to the actual name of my child theme and he said I should. I am not entirely sure why I never changed this but I am planning on doing that right now. The problem is that I still would never know if it is working or not.
So without changing anything from what was given to me except the name of the child theme I am guessing the correct code would look something like this :
function gridbox-child_footer_text() {
echo get_the_date( 'Y' );
}
add_action( 'gridbox_footer_text', 'child_theme_footer_text' );
There is a dash instead of an underscore in the gridbox-child name. So I assume this is what is supposed to be used.
The two main questions are 1. Would this work correctly? If not then what would? and 2. How would I ever know?