下面是从中提取信息的文件。
我尝试将/inc文件夹添加到子主题并添加模板标记。php已更改,但这不会产生任何影响。
/wp内容/主题/hestia/inc/模板标签。php
这是这里的原始代码…
function hesta_bottom_footer_content( $is_callback = false ) {
if ( ! $is_callback ) {
?>
<div class="hestia-bottom-footer-content">
<?php
}
$hestia_general_credits = get_theme_mod(
\'hestia_general_credits\',
sprintf(
/* translators: %1$s is Theme Name, %2$s is WordPress */
esc_html__( \'%1$s | Powered by %2$s\', \'hestia\' ),
sprintf(
/* translators: %s is Theme name */
\'<a href="https://themeisle.com/themes/hestia/" target="_blank" rel="nofollow">%s</a>\',
esc_html__( \'Hestia\', \'hestia\' )
),
/* translators: %s is WordPress */
sprintf(
\'<a href="%1$s" rel="nofollow">%2$s</a>\',
esc_url( __( \'http://wordpress.org\', \'hestia\' ) ),
esc_html__( \'WordPress\', \'hestia\' )
)
)
);
$hestia_copyright_alignment = get_theme_mod( \'hestia_copyright_alignment\', \'right\' );
$menu_class = \'pull-left\';
$copyright_class = \'pull-right\';
switch ( $hestia_copyright_alignment ) {
case \'left\':
$menu_class = \'pull-right\';
$copyright_class = \'pull-left\';
break;
case \'center\':
$menu_class = \'hestia-center\';
$copyright_class = \'hestia-center\';
}
wp_nav_menu(
array(
\'theme_location\' => \'footer\',
\'depth\' => 1,
\'container\' => \'ul\',
\'menu_class\' => \'footer-menu \' . esc_attr( $menu_class ),
)
);
?>
<?php if ( ! empty( $hestia_general_credits ) || is_customize_preview() ) : ?>
<div class="copyright <?php echo esc_attr( $copyright_class ); ?>">
<?php echo wp_kses_post( $hestia_general_credits ); ?>
</div>
<?php endif; ?>
<?php
if ( ! $is_callback ) {
?>
</div>
<?php
}
}
这与我想做的更改是相同的代码,即“设计人”部分
function hesta_bottom_footer_content( $is_callback = false ) {
if ( ! $is_callback ) {
?>
<div class="hestia-bottom-footer-content">
<?php
}
$hestia_general_credits = get_theme_mod(
\'hestia_general_credits\',
sprintf(
/* translators: %1$s is Theme Name, %2$s is WordPress */
esc_html__( \'Designed by HCL Design\' ),
sprintf(
/* translators: %s is Theme name */
\'<a href="https://themeisle.com/themes/hestia/" target="_blank" rel="nofollow">%s</a>\',
esc_html__( \'Hestia\', \'hestia\' )
),
/* translators: %s is WordPress */
sprintf(
\'<a href="%1$s" rel="nofollow">%2$s</a>\',
esc_url( __( \'http://wordpress.org\', \'hestia\' ) ),
esc_html__( \'WordPress\', \'hestia\' )
)
)
);
$hestia_copyright_alignment = get_theme_mod( \'hestia_copyright_alignment\', \'right\' );
$menu_class = \'pull-left\';
$copyright_class = \'pull-right\';
switch ( $hestia_copyright_alignment ) {
case \'left\':
$menu_class = \'pull-right\';
$copyright_class = \'pull-left\';
break;
case \'center\':
$menu_class = \'hestia-center\';
$copyright_class = \'hestia-center\';
}
wp_nav_menu(
array(
\'theme_location\' => \'footer\',
\'depth\' => 1,
\'container\' => \'ul\',
\'menu_class\' => \'footer-menu \' . esc_attr( $menu_class ),
)
);
?>
<?php if ( ! empty( $hestia_general_credits ) || is_customize_preview() ) : ?>
<div class="copyright <?php echo esc_attr( $copyright_class ); ?>">
<?php echo wp_kses_post( $hestia_general_credits ); ?>
</div>
<?php endif; ?>
<?php
if ( ! $is_callback ) {
?>
</div>
<?php
}
}
那么,是否有必要通过向函数中添加某种函数来进行此更改。php或任何其他文件?任何解决方案都可以让我进行更改,而不是每次主题更新时都进行更改。
在页脚中。php那里只有
<?php do_action( \'hestia_do_footer\' ); ?>
这就是我找到do\\u行动来源的原因。
任何帮助都将不胜感激,请让我知道您需要的任何其他细节,因为这很难解释。
最合适的回答,由SO网友:David Lee 整理而成
您需要修改2个函数,而不仅仅是functions.php
:
/**
* Function to display footer content.
*
* @since 1.1.24
* @access public
*/
//ADDED CHILD TO THE END OF THE NAME
function hestia_the_footer_content_child() {
/**
* Array holding all registered footer widgets areas
*/
$hestia_footer_widgets_ids = array( \'footer-one-widgets\', \'footer-two-widgets\', \'footer-three-widgets\' );
$hestia_footer_class = \'col-md-4\';
$footer_has_widgets = false;
$hestia_nr_footer_widgets = get_theme_mod( \'hestia_nr_footer_widgets\',\'3\' );
/**
* Enabling alternative footer style
*/
$footer_style = \'\';
$footer_style = get_theme_mod( \'hestia_alternative_footer_style\', 0 );
if ( isset( $footer_style ) && $footer_style == 0 ) {
$footer_style = \'footer-black\';
} else {
$footer_style = \'\';
}
/**
* Get the widgets areas ids and class corresponding to the number selected by the user
*/
if ( ! empty( $hestia_nr_footer_widgets ) ) {
$hestia_footer_widgets_ids = array_slice( $hestia_footer_widgets_ids, 0, $hestia_nr_footer_widgets );
switch ( $hestia_nr_footer_widgets ) {
case 1:
$hestia_footer_class = \'col-md-12\';
break;
case 2:
$hestia_footer_class = \'col-md-6\';
break;
case 3:
$hestia_footer_class = \'col-md-4\';
break;
case 4:
$hestia_footer_class = \'col-md-3\';
break;
}
}
/**
* Check if the selected footer widgets areas are not empty
*/
if ( ! empty( $hestia_footer_widgets_ids ) ) {
foreach ( $hestia_footer_widgets_ids as $hestia_footer_widget_item ) {
$footer_has_widgets = is_active_sidebar( $hestia_footer_widget_item );
if ( $footer_has_widgets ) {
break;
}
}
}
hestia_before_footer_trigger();
?>
<footer class="footer <?php echo esc_attr( $footer_style ); ?> footer-big">
<?php hestia_before_footer_content_trigger(); ?>
<div class="container">
<?php
if ( $footer_has_widgets ) {
?>
<div class="content">
<div class="row">
<?php
if ( ! empty( $hestia_footer_widgets_ids ) ) {
foreach ( $hestia_footer_widgets_ids as $hestia_footer_widget_item ) {
if ( is_active_sidebar( $hestia_footer_widget_item ) ) {
echo \'<div class="\' . $hestia_footer_class . \'">\';
dynamic_sidebar( $hestia_footer_widget_item );
echo \'</div>\';
}
}
}
?>
</div>
</div>
<hr/>
<?php
}
?>
<?php hestia_before_footer_widgets_trigger(); ?>
<div class="hestia-bottom-footer-content">
<?php
//ADDED CHILD THIS IS THE CALL TO THE COPYRIGHT
hesta_bottom_footer_content_child();
?>
</div>
<?php hestia_after_footer_widgets_trigger(); ?>
</div>
<?php hestia_after_footer_content_trigger(); ?>
</footer>
<?php
hestia_after_footer_trigger();
}
//WE CHANGE THE ACTION NAME AND THE CALL IS TO OUR FUNCTION NOW
add_action( \'hestia_do_footer_child\', \'hestia_the_footer_content_child\' );
//THIS IS YOUR MODIFIED FUNCTION
function hesta_bottom_footer_content_child( $is_callback = false ) {
if ( ! $is_callback ) {
?>
<div class="hestia-bottom-footer-content">
<?php
}
$hestia_general_credits = get_theme_mod(
\'hestia_general_credits\',
sprintf(
/* translators: %1$s is Theme Name, %2$s is WordPress */
esc_html__( \'Designed by HCL Design\' ),
sprintf(
/* translators: %s is Theme name */
\'<a href="https://themeisle.com/themes/hestia/" target="_blank" rel="nofollow">%s</a>\',
esc_html__( \'Hestia\', \'hestia\' )
),
/* translators: %s is WordPress */
sprintf(
\'<a href="%1$s" rel="nofollow">%2$s</a>\',
esc_url( __( \'http://wordpress.org\', \'hestia\' ) ),
esc_html__( \'WordPress\', \'hestia\' )
)
)
);
$hestia_copyright_alignment = get_theme_mod( \'hestia_copyright_alignment\', \'right\' );
$menu_class = \'pull-left\';
$copyright_class = \'pull-right\';
switch ( $hestia_copyright_alignment ) {
case \'left\':
$menu_class = \'pull-right\';
$copyright_class = \'pull-left\';
break;
case \'center\':
$menu_class = \'hestia-center\';
$copyright_class = \'hestia-center\';
}
wp_nav_menu(
array(
\'theme_location\' => \'footer\',
\'depth\' => 1,
\'container\' => \'ul\',
\'menu_class\' => \'footer-menu \' . esc_attr( $menu_class ),
)
);
?>
<?php if ( ! empty( $hestia_general_credits ) || is_customize_preview() ) : ?>
<div class="copyright <?php echo esc_attr( $copyright_class ); ?>">
<?php echo wp_kses_post( $hestia_general_credits ); ?>
</div>
<?php endif; ?>
<?php
if ( ! $is_callback ) {
?>
</div>
<?php
}
}
现在在
footer.php
我们称我们的行动为:
<?php do_action( \'hestia_do_footer_child\' ); ?>
即使您修改了该函数,版权的实际函数也被另一个函数调用,因此您也需要制作该函数的自己版本,以便它调用您修改的函数。