Hi everyone I have a question how can you create a dynamic copyright in WordPress with URL that goes back to the home page as well as a URL that goes to the designer of the theme
Hi everyone I have a question how can you create a dynamic copyright in WordPress with URL that goes back to the home page as well as a URL that goes to the designer of the theme
Share Improve this question edited Feb 15, 2019 at 12:24 Johansson 15.4k11 gold badges43 silver badges79 bronze badges asked Feb 15, 2019 at 9:52 tmmcursisttmmcursist 13 bronze badges3 Answers
Reset to default 1The fastest way is to look for the current copyright text inside your theme's footer.php
file and substitute it with something more of your liking.
My suggestion, as I don't know what you mean for "dynamic", is to substitute the current text with a function call, like <?php my_copyright_text() ?>
, and then define that function in your theme's function.php
file in which you do whatever you need to do.
function my_copyright_text(){
$year = date("Y",time());
$company = "Mycompany";
echo "© 2018-$year $company"; //this is effectively HTML code
}
As the output of the function is HTML code you can insert tags and css classes as you like. For example "© 2018-$year <span class="company">Mycompany</span>"
.
It is strongly suggested to use a child theme, as not to let theme updates overwrite your tweaks.
If you feel brave you can put some of the parameters in the theme customizer, take a look here.
below code Update Copyright Year in a Website Dynamically
© 2018 – <?php echo date('Y'); ?> <a href="#url">YourSite</a>
First you can put below code in your theme's functions.php file.
<?php
function copyright_text(){
$previous_year = date('Y') - 1;
$current_year = date('Y');
$company_url = esc_url(home_url('/'));
$designer_url = 'http://www.designer-url';
echo '<div>© copyright '.$previous_year.' - '.$current_year.'<a href='.$company_url.' class="comp"> company </a> and <a href='.$designer_url.' class="desg" taret="_blank"> designer </a></div>';
}
?>
And Second you can use this code <?php echo copyright_text(); ?>
where you want to display copyright in footer like your theme's footer.php file.
Hope this code may help you. I have tested this code and it's working fine.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745420396a4626937.html
评论列表(0条)