Site logo

Archived topic

PHP in footer hook

5 replies · Started by Lisa on February 11, 2021

Viewing posts 1–6 of 6

I'm using the Coach theme and am trying to insert an auto date via PHP to the footer copyright text and am not having luck. That area is a hooked element. I've tried inserting it directly in the existing block, created a code block and tried inline code to no avail. I've searched the forum and can't find a solution. Is it possible?

Hi there,

I'm not exactly sure what you're trying to achieve but consider this:

You can control what displays as the copyright using generate_copyright filter.

Example: add a "your text" before the copyright message.

add_filter( 'generate_copyright', function($copyright){
$edited_copyright = 'your text '.$copyright;
return $edited_copyright;
},15,1);

Another example, say you want to apply a dynamic content like the current date after the copyright message.

You can try this PHP snippet:

add_filter( 'generate_copyright', function($copyright){
$currdate = date("Y/m/d");
$edited_copyright = $copyright.' '.$currdate;
return $edited_copyright;
},15,1);

Reference site: https://poeinfo.karabinerdesign.net
My bad for the poor initial description of the issue. I'm developing a site using the Coach theme from the GeneratePress site library. In the footer there's an area that lets you add a copyright statement, © Your Copyright Message, but it's added in a text block. I'm assuming using the filter above would add a section, correct?

I wanted to add a bit of PHP to display the current year (<?php echo date("Y"); ?>) so it would always show the current year and read, © 2021 Your Copyright Message. I can't get it to work. I've tried using an HTML block and a code block, to no avail. The result always displays © <?php echo date("Y"); ?> Chris Poe.

I'm looking to find out if this is possible or do I need to add a separate copyright area at the very bottom.

That worked, Leo. Thank you!

No problem :)

This archived topic is closed to new replies.