• Resolved New_WP

    (@baxter89)


    Hello,
    How to have a copyright with the year automatically at the bottom of the page.
    Thanks

Viewing 5 replies - 1 through 5 (of 5 total)
  • Gojero

    (@gojero)

    Hi,

    I solved this one recently.
    Add a shortcode in function.php

    //--- Add a shortcode for showing current year - [year]
    	function year_shortcode() {
    	  $year = date('Y');
    	  return $year;
    	}
    	add_shortcode('year', 'year_shortcode');
    //--- END ---

    Shortcode in your pages/texts and footer: [year]

    Gojero

    (@gojero)

    Hi,

    I forgot to mention that it is important to make a child theme with its own function.php and style.css; To be sure that future twenty three updates will not override all your custom codes. But yeah, this will happen to every wp beginner. including me ??

    Thread Starter New_WP

    (@baxter89)

    Thanks,
    We can find where a child theme for the twenty twenty three theme
    Do you need a special theme for the FSE versions?
    Thanks

    Moderator Kathryn Presner

    (@zoonini)

    @gojero Thanks for sharing that function!

    To use that in a block theme with site editing, you’d only need to put the shortcode in a shortcode block in your footer template part.

    @baxter89 You don’t need a child theme if all you’re doing is adding custom functions to a theme. You can use a functionality plugin instead – either by creating your own, or using a premade one like this one:

    https://www.ads-software.com/plugins/code-snippets/

    If you prefer to make a child theme, I’d suggest using the Create Block Theme plugin, selecting the child theme option:

    https://www.ads-software.com/plugins/create-block-theme/

    There are other ways to render a PHP date function by adding code directly to your footer template (in a child theme), but it’s a little more complicated with a block theme, since templates are HTML files and not PHP. If you’re interested in exploring that avenue, check out this guide to rendering PHP in site editing templates.

    Moderator Kathryn Presner

    (@zoonini)

    As it’s been over a month since the last reply here, I’m going ahead and marking this as resolved. If you still need further help, don’t hesitate to start a new thread.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Copyright’ is closed to new replies.