最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

How to edit footer

programmeradmin4浏览0评论

I'm using the ColorMag theme and I wanted to know how to edit the footer. What I've found is that:

<?php do_action( 'colormag_footer_copyright' ); ?>

Is showing the footer and I need to edit customizer.php for that purpose but don't know what to edit as I've seen deleting a single line is resulting drastically so I don't want to risk more by random tries.

I'm using the ColorMag theme and I wanted to know how to edit the footer. What I've found is that:

<?php do_action( 'colormag_footer_copyright' ); ?>

Is showing the footer and I need to edit customizer.php for that purpose but don't know what to edit as I've seen deleting a single line is resulting drastically so I don't want to risk more by random tries.

Share Improve this question edited May 13, 2017 at 12:44 Ethan Rævan 4,0295 gold badges27 silver badges55 bronze badges asked May 13, 2017 at 12:17 Black MambaBlack Mamba 1431 silver badge5 bronze badges 1
  • Have you contacted the ColorMag themes support? – Tom J Nowell Commented May 13, 2017 at 12:47
Add a comment  | 

5 Answers 5

Reset to default 2

At first go to theme directory find inc>functions.php then search for "colormag_footer_copyright" edit this code bellow as you need:

add_action( 'colormag_footer_copyright', 'colormag_footer_copyright', 10 );
/**
 * function to show the footer info, copyright information
 */
if ( ! function_exists( 'colormag_footer_copyright' ) ) :
function colormag_footer_copyright() {
   $site_link = '<a href="' . esc_url( home_url( '/' ) ) . '" title="' . esc_attr( get_bloginfo( 'name', 'display' ) ) . '" ><span>' . get_bloginfo( 'name', 'display' ) . '</span></a>';

   $wp_link = '<a href="https://wordpress" target="_blank" title="' . esc_attr__( 'WordPress', 'colormag' ) . '"><span>' . __( 'WordPress', 'colormag' ) . '</span></a>';

   $tg_link =  '<a href="https://themegrill/themes/colormag" target="_blank" title="'.esc_attr__( 'ThemeGrill', 'colormag' ).'" rel="designer"><span>'.__( 'ThemeGrill', 'colormag') .'</span></a>';

   $default_footer_value = sprintf( __( 'Copyright &copy; %1$s %2$s. All rights reserved.', 'colormag' ), date( 'Y' ), $site_link ).'<br>'.sprintf( __( 'Theme: %1$s by %2$s.', 'colormag' ), 'ColorMag', $tg_link ).' '.sprintf( __( 'Powered by %s.', 'colormag' ), $wp_link );

   $colormag_footer_copyright = '<div class="copyright">'.$default_footer_value.'</div>';
   echo $colormag_footer_copyright;
}
endif;

Login to your WordPress Dashboard.

Go to Appearance => Themes => Editor

Select inc/functions.php from the right side bar.

Search for colormag_footer_copyright and delete the following code.

$wp_link = '<a href="http://wordpress" target="_blank" title="' . esc_attr__( 'WordPress', 'colormag' ) . '"><span>' . __( 'WordPress', 'colormag' ) . '</span></a>';

From the below code, delete the code from br tag to end

$default_footer_value = sprintf( __( 'Copyright &copy; %1$s %2$s. All rights reserved.', 'colormag' ), date( 'Y' ), $site_link ).'<br>'.sprintf( __( 'Theme: %1$s by %2$s.', 'colormag' ), 'ColorMag', $tg_link ).' '.sprintf( __( 'Powered by %s.', 'colormag' ), $wp_link );

After deleting the above code which is highlighted in bold, ensure that you have the following code:

$default_footer_value = sprintf( __( 'Copyright &copy; %1$s %2$s. All rights reserved.', 'colormag' ), date( 'Y' ), $site_link );

After deleting the above code which is highlighted in bold, ensure that you have the following code:

$default_footer_value = sprintf( __( 'Copyright &copy; %1$s %2$s. All rights reserved.', 'colormag' ), date( 'Y' ), $site_link );

Source

The action colormag_footer_copyright echos a copyright note. if yout want to replace it with your name, you can do it like this:

add_action( 'colormag_footer_copyright', 'my_copyright', 10, 3 );

function my_copyright() {
    echo '&copy; Ishan Mahajan '.date('Y');
}

for example.

if you want to edit the whole footer you can edit the footer.php in your theme folder.

Just comment out the theme and wordpress lines. In the inc/function.php file like this:

/*. '<br>' . sprintf( __( 'Theme: %1$s by %2$s.', 'colormag' ), 'ColorMag', $tg_link ) . ' ' . sprintf( __( 'Powered by %s.', 'colormag' ), $wp_link )*/;

FYI For some reason I can only do this in the colormag folder but not the child folder.

Also don't try to delete this line in footer.php

<?php do_action( 'colormag_footer_copyright' ); ?>

It will lose edit bar and other functions in customize.

You should never edit theme's files directly because you'll loose it on the next theme update. Here is what I did in my Child Theme functions.php created of ColorMag 1.4.2:

// Function to add my copyright
function child_colormag_footer_copyright() {
    echo '<div class="copyright">© My Copyright '.date('Y').'</div>';
}
// Function hook
add_action( 'colormag_footer_copyright', 'child_colormag_footer_copyright', 11 );

// Function to remove parent function
function child_remove_parent_function() {
    remove_action(  'colormag_footer_copyright', 'colormag_footer_copyright');
}
// Hook removal function
add_action( 'wp_loaded', 'child_remove_parent_function' );
发布评论

评论列表(0)

  1. 暂无评论