ファイルの階層は375さんが書かれているままで、子テーマのfunctions.phpに親テーマのfunctions.phpから以下をコードを持ってきて一部書き換えてください。
php
1function sydney_widgets_initx() { //関数名を変更
2 register_sidebar( array(
3 'name' => __( 'Sidebar', 'sydney' ),
4 'id' => 'sidebar-1',
5 'description' => '',
6 'before_widget' => '<aside id="%1$s" class="widget %2$s">',
7 'after_widget' => '</aside>',
8 'before_title' => '<h3 class="widget-title">',
9 'after_title' => '</h3>',
10 ) );
11
12 //Footer widget areas
13 $widget_areas = get_theme_mod('footer_widget_areas', '3');
14 for ($i=1; $i<=$widget_areas; $i++) {
15 register_sidebar( array(
16 'name' => __( 'Footer ', 'sydney' ) . $i,
17 'id' => 'footer-' . $i,
18 'description' => '',
19 'before_widget' => '<aside id="%1$s" class="widget %2$s">',
20 'after_widget' => '</aside>',
21 'before_title' => '<h3 class="widget-title">',
22 'after_title' => '</h3>',
23 ) );
24 }
25
26 //Register the front page widgets
27 if ( defined( 'SITEORIGIN_PANELS_VERSION' ) ) {
28 register_widget( 'Sydney_Latest_Newsx' ); //クラス名を変更
29 }
30
31}
32add_action( 'widgets_init', 'sydney_widgets_initx' );
33
34if ( defined( 'SITEORIGIN_PANELS_VERSION' ) ) {
35 require get_stylesheet_directory() . "/widgets/fp-latest-news.php"; //表示したいファイル
36}
37
変更したい子テーマのfp-latest-news.phpのファイルのクラス名をfunctions.phpで書き換えたクラス名に変更
php
1class Sydney_Latest_Newsx extends WP_Widget { //クラス名を変更
参考:https://teratail.com/questions/84520
親テーマの上書きではなく、新たに同じ関数を付け加える形ですが……。
参考まで。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/02/06 02:45
2018/09/23 02:39 編集
2021/01/07 00:53