我正在使用ColorMag主题,我想知道如何编辑页脚。我发现:
<?php do_action( \'colormag_footer_copyright\' ); ?>
正在显示页脚,我需要编辑customizer.php
出于这个目的,但我不知道该编辑什么,因为我已经看到删除一行会产生巨大的后果,所以我不想通过随机尝试来冒更大的风险。我正在使用ColorMag主题,我想知道如何编辑页脚。我发现:
<?php do_action( \'colormag_footer_copyright\' ); ?>
正在显示页脚,我需要编辑customizer.php
出于这个目的,但我不知道该编辑什么,因为我已经看到删除一行会产生巨大的后果,所以我不想通过随机尝试来冒更大的风险。首先转到主题目录find inc>functions。php然后搜索“colormag\\u footer\\u copyright”,根据需要编辑以下代码:
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.org" target="_blank" title="\' . esc_attr__( \'WordPress\', \'colormag\' ) . \'"><span>\' . __( \'WordPress\', \'colormag\' ) . \'</span></a>\';
$tg_link = \'<a href="https://themegrill.com/themes/colormag" target="_blank" title="\'.esc_attr__( \'ThemeGrill\', \'colormag\' ).\'" rel="designer"><span>\'.__( \'ThemeGrill\', \'colormag\') .\'</span></a>\';
$default_footer_value = sprintf( __( \'Copyright © %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;
登录WordPress仪表板。
转到外观=>主题=>编辑器
选择inc/functions(增加/功能)。右侧栏中的php。
搜索colormag\\u footer\\u版权并删除以下代码。
$wp_link = \'<a href="http://wordpress.org" target="_blank" title="\' . esc_attr__( \'WordPress\', \'colormag\' ) . \'"><span>\' . __( \'WordPress\', \'colormag\' ) . \'</span></a>\';
从下面的代码中,删除br tag至end的代码$default_footer_value = sprintf( __( \'Copyright © %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 );
删除以粗体突出显示的上述代码后,请确保您具有以下代码:$default_footer_value = sprintf( __( \'Copyright © %1$s %2$s. All rights reserved.\', \'colormag\' ), date( \'Y\' ), $site_link );
删除以粗体突出显示的上述代码后,请确保您具有以下代码:$default_footer_value = sprintf( __( \'Copyright © %1$s %2$s. All rights reserved.\', \'colormag\' ), date( \'Y\' ), $site_link );
行动colormag_footer_copyright
附和版权说明。如果您想用您的名字替换它,可以这样做:
add_action( \'colormag_footer_copyright\', \'my_copyright\', 10, 3 );
function my_copyright() {
echo \'© Ishan Mahajan \'.date(\'Y\');
}
例如。如果要编辑整个页脚,可以编辑footer.php
在主题文件夹中。
只需注释掉主题和wordpress行即可。在inc/功能中。php文件如下:
/*. \'<br>\' . sprintf( __( \'Theme: %1$s by %2$s.\', \'colormag\' ), \'ColorMag\', $tg_link ) . \' \' . sprintf( __( \'Powered by %s.\', \'colormag\' ), $wp_link )*/;
仅供参考,由于某些原因,我只能在colormag文件夹中执行此操作,但不能在子文件夹中执行。也不要尝试删除页脚中的这一行。php
<?php do_action( \'colormag_footer_copyright\' ); ?>
它将丢失“自定义”中的编辑栏和其他功能。你不应该直接编辑主题的文件,因为你会在下一次主题更新时丢失它。以下是我在我的孩子主题中所做的functions.php
根据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\' );
我正在尝试修改页脚中排队脚本的插件,因为我的jQuery链接在页脚中。插件:add_action(\'wp_enqueue_scripts\', \'fjgwpp_addCSSandJS\'); function fjgwpp_addCSSandJS() { //Register scripts wp_register_script( \'justifiedGallery\', plugins_url(\'