Navigation
This is archived content. Visit our new forum.
  • Author
    Posts
  • #39094

    Paul Harvey
    Participant

    I could hack my child footer.php and call the_date(‘y’) but I’d like to stick with the proper way of doing things inside the X, which I’m guessing is creating a new shortcode and adding it to the Customizer?

    I tried to create a new shortcode but there wasn’t anywhere to add the PHP snippet. What am I doing wrong?

    #39308

    Support
    Member

    Hi Paul,

    Personally, I wouldn’t worry about calling the_date function on a footer as it is just a tiny bit and would not affect anything on your theme except displaying the year. If you want to utilize Customizer, you can just utilize the Footer Content and Customizer > Footer.

    #42900

    Paul Harvey
    Participant

    Thank you, but I tried adding the php snippet <?php the_date('Y'); ?> to the Footer Content field in Customizer, but it appears that PHP code is not processed in this field. What next?

    #42920

    Migs
    Participant

    There are plugins which allow scripts to be run in WPpages. Whether these would be effective in the Customizer, however, I’m not sure.

    Is there a reason why you don’t just add ©2014 (or whatever) to the footer?

    #43096

    Christian
    Moderator

    Hey Paul,

    PHP is not allowed in the Customizer for security reasons. You need to manually add the year to the footer like what Migs suggested. Your request is possible technically but that falls beyond our scope of support.

    Thank you for understanding.

    #43307

    Paul Harvey
    Participant

    Really, you guys can’t possibly be the programmers that built X. These “band-aid” approaches are not how a programmer thinks. There is always a “right way” that the developers intended.

    I’ll assume it’s shortcodes, so you can close this ticket.

    #43578

    Alexander
    Keymaster

    Hey Paul,

    I’m sorry we weren’t able to provide more information before. We have some resources in our knowledge base that should assist you here. I’ll provide links to them, and expand a bit on the issue at hand.

    I’d advise that you setup a child theme. This allows you to make PHP code changes that won’t be overwritten when an X update is released. After your child theme is setup, please review how we recommend making template changes in Customization Best Practices.

    Once you have that setup, you will want to copy this file to your child theme (depends on stack):

    x/framework/views/{stack}/wp-footer.php

    Look for this:

    <div class="x-colophon-content">
        <?php echo get_theme_mod( 'x_footer_content' ); ?>
    </div>

    You could add a Copyright + year with something like this:

    <div class="x-colophon-content">
        <?php echo 'Copyright &copy;' . date('Y') . ' Company Name'; ?>
        <?php echo get_theme_mod( 'x_footer_content' ); ?>
    </div>

    An alternative would be to modify that code to accept shortcodes. For example:

    <div class="x-colophon-content">
        <?php echo do_shortcode(get_theme_mod( 'x_footer_content' ) ); ?>
    </div>

    Then in functions.php of your child theme, you could add a custom year shortcode with this:

    function x_get_this_year() { return date('Y'); }
    add_shortcode('year', 'x_get_this_year');

    So you’d finally be able to simply add Company &copy; [year] in the Footer custom content.

    Let us know how it goes!

    #44689

    Migs
    Participant

    I’m going to add my twopennarth back into this thread (as a non-X team member, I should add)

    In all the web designs I’ve done over the years (lots of them with significant amounts of hand coding in the early days of php/mysql driven and WYSIWYG sites), a significant number of them have neither required nor wanted the year adding to the footer. I do understand why someone might want the function built in, but it’s easier to add than to remove. This is especially true when, as is the case with X, the Customizer allows it to be done with the minimum of fuss. It saves me hacking core code or having to create a child theme. It also prevents those with more limited knowledge of the “under the hood” stuff from potentially killing their site.

    I certainly don’t see the X-method of footer implementation as a “band-aid” solution, I actually see it as adding ultimate control over what is included in the footer. I don’t expect everybody to prefer it this way, but it’s the right way for me.

    Perhaps as the developers intended 😉

    #44935

    Rad
    Moderator

    Yes Migs, it was intended that way. And as my point of view, it is not good to always evaluate your content when there is nothing to evaluate like shortcodes or php (performance wise).

    So I added a feature on my list, something like shortcode toggle (enable/disable) support for Footer and topbar content.

    Thank you for your input Migs! It helps 🙂

    #641350

    WPH2o
    Participant

    Here’s the MUCH MORE SIMPLE way to get this done:

    https://community.theme.co/forums/topic/add-current-year-to-footer/#post-226892

    In my case I needed to add script tags around the jquery code to get it to work.

    In my case I’m constantly building or re-developing client sites and EVERY ONE OF THEM wants a current copyright date in their footer.

    #641376

    Paul R
    Moderator

    @WPHo2 Thanks for sharing the link on this thread.

    Have anice day! 🙂