Tagged: child theme, theme options
- This topic has 6 replies, 2 voices, and was last updated 10 years, 6 months ago by prajakta.
-
AuthorPosts
-
June 5, 2014 at 4:59 pm #33607prajaktaMember
How to edit theme_options.php without editing the parent theme ??
I have catch-kathmandu theme.I have created its child theme. I have made certain changes in theme_options.php (inc/panel/theme_options.php -> catchkathmandu_theme_options_do_page() function ). To make the changes work i had to comment following line in my parent’s function.php
require( get_template_directory() . ‘/inc/panel/theme-options.php’ );
similarly i had to add the following in my child theme’s function.php
require( get_stylesheet_directory() . ‘/inc/panel/theme-options.php’ );Is there any way to make the changes without making any changes to parent theme ?
June 6, 2014 at 1:15 am #33669SakinKeymaster@prajakta: Sorry I don’t think moving the theme-options.php to child theme will work as it depends on so many files. So, it will be better that you create additional option in your child theme or use plugin like Options Framework to add additional option in your child theme.
June 25, 2014 at 8:09 pm #36294prajaktaMember@sakin: Moving the file theme_options.php is working…[pls refer my question].I need to change this function
inc/panel/theme_options.php -> catchkathmandu_theme_options_do_page() function as i am adding one theme option field here.I think catchkathmandu_theme_options_do_page() could be overwritten if function_exists was used.Can we do this in future versions ? or is there any way out
I Just need to add a single field so Options Framework is expensive …can anybody help with the other way…i am new to wordpress
June 25, 2014 at 11:00 pm #36312SakinKeymaster@prajakta: Option Framework will not be expensive and it is just on backed. Also if you need, you can add option by creating child theme option panel. Here is the sample code that you can add in your child theme
functions.php
fileadd_action( 'admin_menu', 'catchkathmandu_child_options_menu' ); /* * Create a function for Theme Options Page * * @uses add_menu_page * @add action admin_menu */ function catchkathmandu_child_options_menu() { add_theme_page( __( 'Theme Options Child', 'catchkathmandu' ), // Name of page __( 'Theme Options Child', 'catchkathmandu' ), // Label in menu 'edit_theme_options', // Capability required 'child_theme_options', // Menu slug, used to uniquely identify the page 'catchkathmandu_child_theme_options_do_page' // Function that renders the options page ); } /* * Render Catch Kathmandu Child Theme Options page * * @uses settings_fields, get_option, bloginfo * @Settings Updated */ function catchkathmandu_child_theme_options_do_page() { }
June 26, 2014 at 12:16 pm #36396prajaktaMemberThanks for the reply …I just need to clarify that will not executing 1200-1400 same lines again for just 10 lines of modification in this function affect the performance…or is there any other efficient way
or can we do something like this in child’s function.php
remove_action( ‘admin_menu’, ‘catchkathmandu_options_menu’ );
add_action( ‘admin_menu’, ‘catchkathmandu_child_options_menu’ );function catchkathmandu_child_options_menu() {
add_theme_page(
__( ‘Theme Options’, ‘catchkathmandu’ ), // Name of page
__( ‘Theme Options’, ‘catchkathmandu’ ), // Label in menu
‘edit_theme_options’, // Capability required
‘theme_options’, // Menu slug, used to uniquely identify the page
‘catchkathmandu_child_theme_options_do_page’ // Function that renders the options page
);function catchkathmandu_child_theme_options_do_page() {
}Is this way correct ?
I am not sure whether removing the action stops it from executing the old function catchkathmandu_theme_options_do_page()June 26, 2014 at 11:40 pm #36485SakinKeymaster@prajakta: if you want to remove action and add your own then it will like below:
// Removing the Default Action Hook function unhook_catchkathmandu_functions() { remove_action( 'admin_menu', 'catchkathmandu_options_menu' ); } add_action( 'init', 'unhook_catchkathmandu_functions' ); add_action( 'admin_menu', 'catchkathmandu_child_options_menu' ); function catchkathmandu_options_menu() { add_theme_page( __( 'Theme Options', 'catchkathmandu' ), // Name of page __( 'Theme Options', 'catchkathmandu' ), // Label in menu 'edit_theme_options', // Capability required 'theme_options', // Menu slug, used to uniquely identify the page 'catchkathmandu_child_theme_options_do_page' // Function that renders the options page ); } function catchkathmandu_child_theme_options_do_page() { }
June 27, 2014 at 12:07 pm #36570prajaktaMemberThanks for the reply..just want to know whether removing the action stops it from executing the old function catchkathmandu_theme_options_do_page() …is there any plugin availbale to see hooks and the actions applied to them while executing…I tried Hook Sniffer but it’s crashing as its outdated.
-
AuthorPosts
- The topic ‘Unable to edit theme_options.php without editing the parent theme’ is closed to new replies.