【问题标题】:Wordpress: Remove site info in functions.phpWordpress:删除 functions.php 中的站点信息
【发布时间】:2017-04-19 22:57:41
【问题描述】:

我有一个小问题。我正在开发一个带有 wordpress 和主题“barletta”的网站。此主题将文本添加到我要删除的页脚中。通常我通过编辑footer.php 来做到这一点,但这个主题是不同的。我必须更改functions.php,因为有这段代码:

function barletta_footer_credits() {
?>
<div class="site-info">
<?php if (get_theme_mod('barletta_footer_text') == '') { ?>
&copy; <?php echo date('Y'); ?> <?php bloginfo( 'name' ); ?><?php esc_html_e('. All rights reserved.', 'barletta'); ?>
<?php } else { echo esc_html( get_theme_mod( 'barletta_footer_text', 'barletta' ) ); } ?>
</div><!-- .site-info -->

<?php
$nofollow="";
if (!is_home()) { $nofollow="rel=\"nofollow\""; }
printf( esc_html__( 'Theme by %1$s Powered by %2$s', 'barletta' ) , '<a href="http://moozthemes.com/" target="_blank" '.$nofollow.'>MOOZ Themes</a>', '<a href="http://wordpress.org/" target="_blank">WordPress</a>');
} 
add_action( 'barletta_footer', 'barletta_footer_credits' );

我的 PHP 不太好,所以我的问题是:如何编辑此代码以使 site-info-div 仍显示但不显示打印文本(由...提供支持)?

【问题讨论】:

    标签: php wordpress themes footer


    【解决方案1】:

    你应该删除最后一个 if 检查:

    function barletta_footer_credits() {
    ?>
        <div class="site-info">
            <?php if (get_theme_mod('barletta_footer_text') == '') { ?>
                &copy; <?php echo date('Y'); ?> <?php bloginfo( 'name' ); ?><?php esc_html_e('. All rights reserved.', 'barletta'); ?>
            <?php } else { echo esc_html( get_theme_mod( 'barletta_footer_text', 'barletta' ) ); } ?>
        </div><!-- .site-info -->
    <?php
    }
    add_action( 'barletta_footer', 'barletta_footer_credits' );
    

    【讨论】:

      【解决方案2】:

      只需从

      更改代码
      function barletta_footer_credits() {
      ?>
      <div class="site-info">
      <?php if (get_theme_mod('barletta_footer_text') == '') { ?>
      &copy; <?php echo date('Y'); ?> <?php bloginfo( 'name' ); ?><?php esc_html_e('. All rights reserved.', 'barletta'); ?>
      <?php } else { echo esc_html( get_theme_mod( 'barletta_footer_text', 'barletta' ) ); } ?>
      </div><!-- .site-info -->
      
      <?php
      $nofollow="";
      if (!is_home()) { $nofollow="rel=\"nofollow\""; }
      printf( esc_html__( 'Theme by %1$s Powered by %2$s', 'barletta' ) , '<a href="http://moozthemes.com/" target="_blank" '.$nofollow.'>MOOZ Themes</a>', '<a href="http://wordpress.org/" target="_blank">WordPress</a>');
      } 
      add_action( 'barletta_footer', 'barletta_footer_credits' );
      

      有关注

      function barletta_footer_credits() {
      ?>
      <div class="site-info">
      <?php if (get_theme_mod('barletta_footer_text') == '') { ?>
      &copy; <?php echo date('Y'); ?> <?php bloginfo( 'name' ); ?><?php esc_html_e('. All rights reserved.', 'barletta'); ?>
      <?php } else { echo esc_html( get_theme_mod( 'barletta_footer_text', 'barletta' ) ); } ?>
      </div><!-- .site-info -->
      
      } 
      add_action( 'barletta_footer', 'barletta_footer_credits' );
      

      那只是删除整块

      <?php
      $nofollow="";
      if (!is_home()) { $nofollow="rel=\"nofollow\""; }
      printf( esc_html__( 'Theme by %1$s Powered by %2$s', 'barletta' ) , '<a href="http://moozthemes.com/" target="_blank" '.$nofollow.'>MOOZ Themes</a>', '<a href="http://wordpress.org/" target="_blank">WordPress</a>');
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2012-07-12
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-05-07
        • 1970-01-01
        • 2022-10-31
        相关资源
        最近更新 更多