首页 > 解决方案 > WordPress子主题不覆盖更改

问题描述

我的 WordPress 安装中有两个主题,theme1theme1-child(设置为活动)。

有一部分theme1我想编辑,theme1/inc/templates/post-meta.php

if ( ! function_exists( 'theme1_entry_date' ) ) :
function theme1_entry_date( $echo = true ) {
    if ( has_post_format( array( 'chat', 'status' ) ) )
        $format_prefix = _x( '%1$s on %2$s', '1: post format name. 2: date', 'theme1' );
    else
        $format_prefix = '%2$s';


    $date = sprintf( __( ' on ', 'theme1' ) . '<a href="%1$s" title="%2$s" rel="bookmark"><time class="entry-date" datetime="%3$s">%4$s</time></a>',
        esc_url( get_permalink() ),
        esc_attr( sprintf( __( 'Permalink to %s', 'theme1' ), the_title_attribute( 'echo=0' ) ) ),
        esc_attr( get_the_date( 'c' ) ),
        esc_html( sprintf( $format_prefix, get_post_format_string( get_post_format() ), get_the_date() ) )
    );

    if ( $echo )
        echo $date;

    return $date;
}
endif;

style.css

/*
Theme Name: Theme1 Child
Theme URI: http://www.url.com
Description: This is a child theme for Theme1.
Author: Author
Author URI: http: //www.url.com
Template: theme1
Version: 1.0
*/

@import url("../theme1/style.css");

div.woocommerce-tabs ul.tabs{display:none !important;}
html body .resp-tabs-container {margin-bottom: 30px;}
@media screen and (min-width: 800px) {
    html body div.resp-tab-content {
        padding: 10px !important;
    }
}

所以我重新创建了这个文件,并在: 中进行了修改theme1-child/inc/templates/post-meta.php,但是没有显示修改。

任何想法为什么这不接受变化?

标签: phpwordpresswordpress-theming

解决方案


您需要将theme1_entry_date函数粘贴到您的子主题functions.php文件中。

谢谢


推荐阅读