wpfooter - juedaiyuer/researchNote GitHub Wiki

wordpress修改页脚版权信息

外观-编辑

<a href="<?php echo esc_url( __( 'https://wordpress.org/', 'twentyfourteen' ) ); ?>"><?php printf( __( 'Proudly powered by %s', 'twentyfourteen' ), 'WordPress' ); ?></a>

底部添加页脚动态版权时间

//显示网站运营版权时间
function auto_copyright() {
    global $wpdb;
    $first = $wpdb->get_results("
    SELECT user_registered
    FROM   $wpdb->users  
    ORDER BY  ID ASC
    LIMIT 0,1
    ");
    $output = '';
    $current = date(Y) ;
    if($first) {
    $first=date(Y,strtotime($first[0]->user_registered));
    $copyright = "© " . $first;
    if($first != $current) {
    $copyright .= '-' .$current;
    }
    $output = $copyright;
    }
    echo  $output;
}

将Timle提供的实现代码添加到主题的function.php文件中,方法大家已经熟悉了,“?>”之前。

编辑footer.php文件,在你需要显示的地方添加上调用代码

Twenty fourteen主题页脚定义

  <?php
  /**
   * The template for displaying the footer
   *
   * Contains footer content and the closing of the #main and #page div elements.
   *
   * @package WordPress
   * @subpackage Twenty_Fourteen
   * @since Twenty Fourteen 1.0
   */
  ?>

  		</div><!-- #main -->

  		<footer id="colophon" class="site-footer" role="contentinfo">

  			<?php get_sidebar( 'footer' ); ?>

  			<div class="site-info">
  				<?php do_action( 'twentyfourteen_credits' ); ?>
  				<a href="<?php echo esc_url( __( 'https://wordpress.org/', 'twentyfourteen' ) ); ?>"><?php printf( __( 'Proudly powered by %s', 'twentyfourteen' ), 'WordPress' ); ?></a>
  			</div><!-- .site-info -->
  		</footer><!-- #colophon -->
  	</div><!-- #page -->

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

cosy主题下的底部版权

Copyright © 2017-2018 能源互联网 Design by juedaiyuer  <br />
<span>友情链接</span><li><a href="https://www.nicetheme.cn">NICETHEME</a></li>

source

⚠️ **GitHub.com Fallback** ⚠️