Editing Widgets.php in child theme
-
I give up researching this topic. I want to make minor alterations to part of my widgets.php through the use of a child theme, so far I gather that you cannot simply copy the widgets.php file over because it is a functions file, but I can’t find anywhere that explains what I’m actually supposed to do.
So
class Vantage_Headline_Widget extends WP_Widget { public function __construct() { // widget actual processes parent::__construct( 'headline-widget', // Base ID __('Vantage Headline', 'vantage'), // Name array( 'description' => __( 'A lovely big headline.', 'vantage' ), ) // Args ); } public function widget( $args, $instance ) { echo $args['before_widget']; ?> <h1><?php echo esc_html($instance['headline']) ?></h1> <div class="decoration"><div class="decoration-inside"></div></div> <h3><?php echo wp_kses_post($instance['sub_headline']) ?></h3> <?php echo $args['after_widget']; } public function form( $instance ) { $instance = wp_parse_args( $instance, array( 'headline' => '', 'sub_headline' => '', ) ); ?> <p> <label for="<?php echo $this->get_field_id('headline') ?>"><?php _e('Headline', 'vantage') ?></label> <input type="text" class="widefat" id="<?php echo $this->get_field_id('headline') ?>" name="<?php echo $this->get_field_name('headline') ?>" value="<?php echo esc_attr($instance['headline']) ?>" /> </p> <p> <label for="<?php echo $this->get_field_id('sub_headline') ?>"><?php _e('Sub Headline', 'vantage') ?></label> <input type="text" class="widefat" id="<?php echo $this->get_field_id('sub_headline') ?>" name="<?php echo $this->get_field_name('sub_headline') ?>" value="<?php echo esc_attr($instance['sub_headline']) ?>" /> </p> <?php } }
I think that is the entirety of the code for the widget I’m trying to change, all I want to do is replace the h3 tags with P tags and remove the decoration div in between them. It sounds so simple but apparently it really really isn’t.
I’m using the Vantage theme and the widget in question is called Vantage Headline. Someone please give me something before my head actually explodes.
- The topic ‘Editing Widgets.php in child theme’ is closed to new replies.