Override twentyfourteen functions.php using child theme
-
Hi all,
Please excuse my lack of knowledge when it comes to PHP and WordPress as I try to explain my issue:
I’m creating a child theme using twentyfourteen as parent. The widget-title is wrapped within an <h1> tag. I want to override that <h1> tag with an <h3>.
I tried this code in my child theme functions.php:
function twentyfourteen_cms3_widgets_init() { require get_template_directory() . '/inc/widgets.php'; register_widget( 'Twenty_Fourteen_Ephemera_Widget' ); register_sidebar( array( 'name' => __( 'Primary Sidebar', 'twentyfourteen' ), 'id' => 'sidebar-1', 'description' => __( 'Main sidebar that appears on the left.', 'twentyfourteen' ), 'before_widget' => '<aside id="%1$s" class="widget %2$s">', 'after_widget' => '</aside>', 'before_title' => '<h3 class="widget-title">', 'after_title' => '</h3>', ) ); register_sidebar( array( 'name' => __( 'Content Sidebar', 'twentyfourteen' ), 'id' => 'sidebar-2', 'description' => __( 'Additional sidebar that appears on the right.', 'twentyfourteen' ), 'before_widget' => '<aside id="%1$s" class="widget %2$s">', 'after_widget' => '</aside>', 'before_title' => '<h3 class="widget-title">', 'after_title' => '</h3>', ) ); register_sidebar( array( 'name' => __( 'Footer Widget Area', 'twentyfourteen' ), 'id' => 'sidebar-3', 'description' => __( 'Appears in the footer section of the site.', 'twentyfourteen' ), 'before_widget' => '<aside id="%1$s" class="widget %2$s">', 'after_widget' => '</aside>', 'before_title' => '<h3 class="widget-title">', 'after_title' => '</h3>', ) ); } remove_action( 'widgets_init', 'twentyfourteen_widgets_init' ); add_action( 'widgets_init', 'twentyfourteen_cms3_widgets_init' );
Which throws an error message:
Fatal error: Cannot redeclare class Twenty_Fourteen_Ephemera_Widget in /mypath/wordpress/wp-content/themes/twentyfourteen/inc/widgets.php on line 250When I tried it again without these two lines:
require get_template_directory() . '/inc/widgets.php'; register_widget( 'Twenty_Fourteen_Ephemera_Widget' );
But I still found the ogrinial <h1> tags in the frontend.
How can I successfully accomplish this task?
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Override twentyfourteen functions.php using child theme’ is closed to new replies.