• First, thank you so much for this great theme. I’ve been able to do 99% of what I need.

    I’ve added a custom footer through the Customize interface with a copyright and the year, but I’d really like the year to be dynamic so I don’t have to go in and update it.

    The field allows for HTML, but not javascript or PHP (I tried, hoping).

    I’m trying other avenues such as custom shortcode plugins, but having issues getting them to work in the footer.

    Thoughts on the best way to approach this? Ideally, I would like to NOT edit the footer.php file, as I want to be able to install theme updates without worrying about editing the file again each time (if I need to do that, I could just edit the footer manually January 1st each year).

    Would it be a reasonable feature request for some kind of parameter/variable we could type in this html-only field which will dynamically show the current year? That would be awesome!

    Thanks again!

Viewing 1 replies (of 1 total)
  • Hi Mike. Welcome to the Hueman forum. This is pretty easy to solve using a little jQuery and a function in a child theme. If you’re not currently running a child theme take a look at this documentation:
    http://docs.presscustomizr.com/article/239-using-a-child-theme-with-hueman

    After creating your child theme:

    1. Create a new folder /js in your child theme
    2. Add a new text file named my-scripts.js in the /js folder
    3. Copy this into my-scripts.js:

    // Create dynamic copyright; replace text in footer
    jQuery( document ).ready( function( $ ) {
        var thisYear = new Date().getFullYear();
        var startYear = '2014';
        var myText = ' My Blog    All Rights Reserved';
        $('#copyright p').html('Copyright © ' + startYear + '-' + thisYear + myText);
    })

    You can modify the startYear and myText as needed.

    4. Add this function to your child theme functions.php file to load your script:

    // Load my custom scripts file
    add_action( 'wp_enqueue_scripts', 'add_my_scripts' );
    function add_my_scripts() {
        wp_enqueue_script('my-custom-scripts', get_stylesheet_directory_uri() . '/js/my-scripts.js', array('jquery'),'1.0', true);
    }

    This will put “Copyright © 2014-2016 My Blog All rights reserved” in your footer. You can remove whatever text you added using the Customizer.

Viewing 1 replies (of 1 total)

The topic ‘Current Year in the Footer’ is closed to new replies.