urls - wordpress copyright dynamic

Hi everyone I have a question how can you create a dynamic copyright in WordPress with URL that goes back to the home pa

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 badges
Add a comment  | 

3 Answers 3

Reset to default 1

The 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

&copy; 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>&copy; 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

相关推荐

  • urls - wordpress copyright dynamic

    Hi everyone I have a question how can you create a dynamic copyright in WordPress with URL that goes back to the home pa

    5小时前
    40

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信