You should copy the file you want to edit from the parent to your child theme. This way you can customize the template without touching the actual theme. Paste the code you already have to this template file and you’re good to go.
The following link contains the codex page about creating child themes and modifying the template files: https://codex.wordpress.org/Child_Themes#Template_Files
Hope this helps.
Related Posts:
- How to *remove* a parent theme page template from a child theme?
- How do I make my child theme re-apply the settings that were customised when its parent was active?
- Update widget form after drag-and-drop (WP save bug)
- How do register_sidebar() and get_sidebar() work together?
- How to Add Customizer Setting in Child Theme
- Widgets vs. Theme Mods
- Widgets not working in Customizr but working in Appearance
- Post format selector in Thematic child theme post class
- Get the sidebar ID in which the current widget was dropped
- How Can A Widget With Only One Instance Be Defined?
- How to exclude certain widget from showing up on home/front page? [duplicate]
- Create a customizable child theme
- Customise search form in the Widget
- Schedule cron event from widget
- How to Register and Display Widget for Custom taxonomy
- register_sidebar ‘after_widget’ on custom-built widgets not implementing, caused nested widgets
- How can I & how do I change text displayed in comment via child theme
- Add ‘Right Now’ widget to custom dashboard
- Count widgets of a certain type
- Widget Javascript code (ajax)
- Custom widget select options needs to stay selected after save
- How to build a child theme from a react-based parent theme?
- Custom Widget form function common elements
- Updating Widget options in custom install.php
- Modify a theme to insert custom widgets?
- Customizing default Mediaelement player
- How did I enable atom feeds in a fresh WP3 install?
- How to update preview when custom setting changed in my custom widget
- Warning: Creating default object… when altering Customize panels
- Adding custom field in all widgets, but at the top of the form, in admin area
- How do I change the markup only of a built-in widget?
- Is it possible to make widget return only data (eg, array)?
- How do I call in a category title on a category page in a child theme?
- Is it possible to add a ribbon in the background of h1 on every page?
- Include custom JS without child theme
- Child theme .css files are not overriding their parent .css files
- Allow a Widget to be used one time only?
- Search widget will search everything in the site, how to limit to only search gallery name
- Disable widgets in customizer for sidebar
- Child Theme with multiple css files
- Unable to edit the “customize” section and the “widget” section is populating unknown code
- Choose sidebars column in widgets.php page [closed]
- Can’t receive $args[ ] to my custom widget
- Organizing the position of widgetized areas in the backend
- how to convert Html block to dynamic widget?
- I’d like to move the Widgets Panel to the bottom of the list in Customizer
- How do I remove a customiser option from a parent theme in a child theme?
- CSS Styling a specific page
- Create small dashboard widget
- Is there a way to override require_once of the main theme on the child theme?
- Load File (Function & Variable Value) from Child Theme
- Changes in my child theme from customizer not appearing in style.css?
- Widgets won’t save
- Customizing the Widget content markup
- Widget title markup in register_sidebar
- Sticky menu for WP custom menubars
- Is there another way to customize a parent template file besides adding the file to a child theme?
- css media query question [closed]
- How to customize the WordPress 2014 theme, to have page using less horizontal margin?
- WordPress Child Theme Stylesheet being loaded before Parent’s minified .css
- How to append custom text to the output of ‘categories widget’?
- Customize Widget Navigation
- Changing update message from Newspaper child theme
- Add custom border across footer widget area
- javascript file not working in a plugin template file
- Easily add custom HTML outside the main container?
- Customize section does not show my widget areas
- Trying to customise 2011 Child Theme Background Colour
- Widget recent comment filter by post meta_value
- How could I change contact details in the footer?
- WordPress core jquery version file not loaded?
- How can error pages be customized
- Make Widget appear on Dashboard
- Issue with navigation bar in child theme
- Fixed bottom menu on mobile doesn’t work on search included in Child Theme of Storefront
- Unhook a function within a class in the child theme
- How to narrow the area between buttons on Helium theme sidebar? [closed]
- Calling get_theme_mod() of an WP_Customize_Image_Control() returns an Array, how do I correctly return the image src for my custom theme?
- How to hide or remove a custom widget area when empty
- Execute function with jQuery if widget added or removed?
- Still desperate about multiple TinyMCEs in widgets – is there any good solution to this yet?
- Custom Admin Section
- How to define active widget with js in a customizer
- If a theme will undergo major changes would it be better to clone the parent instead of writting a child theme?
- How do I move my sites to a child theme without loosing customisation?
- Why, when it comes to custom background and image, does ‘The first value registered’ win?
- Changing a setting in the wp-admin/customize.php reverts CSS styles to parent theme [closed]
- Confused about customising widgets
- Special characters showing in fallback font
- customize footer widgets area
- Changes in comments.php in the child theme does not show up on the site
- Word Press Theme Customiser and Child theme Function.php
- How do I include the sidebar (with Widgets) in a custom theme?
- Modifying posts based on category in TwentyTwentyTwo theme
- How do I know if the custom theme is a child theme or a full-custom theme?
- Hover Hide-Visible Additional CSS not working in WordPress website, but shows properly in Customize window
- Add a custom field for sorting the products in a specific category WOOCOMMERCE – Second try
- How to move custom icons from parent theme to the child theme
- Multiple wp.editor in a custom widget using JQuery
- WordPress child theme widget customization – Eduma