Use [copy] and [year] shortcodes in your Divi custom footer text

Jun 22, 2017 | Child Theme, Divi Theme, PHP, Shortcodes

Want to include shortcodes in your Divi theme custom footer text? Using a shortcode for the year means the year will always be current and up-to-date without requiring manual edits.

Click here for instructions to simply rewrite the default Divi footer text into custom text (without the copyright and year shortcodes).

 

Step 1:

Log in to your website’s cpanel and click open the “File Manager”.

You could also access your site files via FTP (File Transfer Protocol) software if you are more familiar with this method.

cpanel file manager

 

Step 2:

Open “public_html” (double-click).

open public_html folder

 

Step 3:

Open “wp-content” folder.

open wp-content folder

 

Step 4:

Open “themes” folder.

themes folder

 

Step 5:

Open your Divi child theme folder.

If you do not have a child theme set up, please refer to the instructions for setting up your Divi child theme.

open child theme folder

 

Step 6:

Create a footer.php file in your child theme folder. Refer to instructions here.

Use the following code for your footer.php file:


<?php if ( 'on' == et_get_option( 'divi_back_to_top', 'false' ) ) : ?>

	<span class="et_pb_scroll_top et-pb-icon"></span>

<?php endif;

if ( ! is_page_template( 'page-template-blank.php' ) ) : ?>

			<footer id="main-footer">
				<?php get_sidebar( 'footer' ); ?>


		<?php
			if ( has_nav_menu( 'footer-menu' ) ) : ?>

				<div id="et-footer-nav">
					<div class="container">
						<?php
							wp_nav_menu( array(
								'theme_location' => 'footer-menu',
								'depth'          => '1',
								'menu_class'     => 'bottom-nav',
								'container'      => '',
								'fallback_cb'    => '',
							) );
						?>
					</div>
				</div> <!-- #et-footer-nav -->

			<?php endif; ?>

				<div id="footer-bottom">
					<div class="container clearfix">
				<?php
					if ( false !== et_get_option( 'show_footer_social_icons', true ) ) {
						get_template_part( 'includes/social_icons', 'footer' );
					}

					$footer_text = et_get_footer_credits();
					echo do_shortcode($footer_text);
				?>
					</div>	<!-- .container -->
				</div>
			</footer> <!-- #main-footer -->
		</div> <!-- #et-main-area -->

<?php endif; // ! is_page_template( 'page-template-blank.php' ) ?>

	</div> <!-- #page-container -->

	<?php wp_footer(); ?>
</body>
</html>

Notice in the “footer-bottom” area, there is the “echo do_shortcode($footer_text)” to allow for the year and copyright shortcodes we will add in the following steps.

 

Step 7:

Right-click and “Edit” your functions.php file.

(See below for adding this if you do not already have this file in your child theme folder.)

edit functions.php file

 

To add a functions.php file, click on “+ File” in the top menu.

file manager add file

 

Add a functions.php file.

add functions.php file

 

Step 8:

Add the following code to the file:

<?php
// 2024 shortcode => 2012
function od_year_shortcode() { return date('Y'); }
add_shortcode('year', 'od_year_shortcode');
// © shortcode => ©
function od_copyright_shortcode() { return '&copy;'; }
add_shortcode('copy', 'od_copyright_shortcode');


 

And save.

save

 

Step 9:

Navigate to Divi>Theme Customizer.

You can do this from the Admin Panel menu (see image),

theme customizer from admin panel

 

OR also from the front using the editing bar (see image).

Navigate to theme customiser from front of website

 

Step 10:

Select “Footer” from the Theme Customizer options.

divi footer settings

 

Step 11:

From there, select “Bottom Bar”.

bottom bar

 

Step 12:

Then save your changes.

Rewrite your own footer into the “EDIT FOOTER CREDITS” text box, using the shortcodes:


©
2024

Then save your changes.

edit footer credits with shortcodes

 

Want more module options for your Divi website?

Check out our Custom Modules for Divi
Browse Custom Modules