Skip to content

Instantly share code, notes, and snippets.

@westcoastdigital
Created September 5, 2017 12:21
Show Gist options
  • Select an option

  • Save westcoastdigital/b7bd1f277d66bdd4fec816a16cb0a883 to your computer and use it in GitHub Desktop.

Select an option

Save westcoastdigital/b7bd1f277d66bdd4fec816a16cb0a883 to your computer and use it in GitHub Desktop.
Custom copyright in GeneratePress whilst still allowing the customiser control to be used
<?php
// Add this to your functions.php of your child theme
function generatepress_custom_copyright() {
$copyrightCustomizer = get_theme_mod('generate_copyright');
if ( !empty($copyrightCustomizer) ) {
$date = date('Y');
$copyrightCustomizer = str_replace( '%current_year%', $date, $copyrightCustomizer );
$copyright = str_replace( '%copy%', '&copy;', $copyrightCustomizer );
// change this to what you want after the copyright
$copyright .= ' | Website built on the <a href="https:$copyrightCustomizer//generatepress.com/">GeneratePress Theme</a>';
} else {
// change this for default copyright if customizer is empty
$copyright = sprintf( '<span class="copyright">&copy; %1$s</span> &bull; <a href="%2$s" target="_blank" itemprop="url">%3$s</a>',
date( 'Y' ),
esc_url( 'https://generatepress.com' ),
__( 'GeneratePress','generatepress' )
);
}
return $copyright;
}
add_filter( 'generate_copyright','generatepress_custom_copyright' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment