Your Time:
Our Time:
← Back to discussions

Changing Template Files in Child Theme

Need help with a different issue? Search the forums or open a new ticket.
Open a support ticket

This topic has 2 replies, 2 voices, and was last updated 12 years, 1 month ago by Fem.

Tagged: 

  • 2014-07-04 at 11:46 pm
    Support Expired
    #4561
    markwhalen
    Participant
    • Topics: 4
    • Replies: 1
    • Total posts: 5
    • Post count: 6

    I’m trying to make some changes to template files (e.g., /framework/shortcode/foodmenu.php) in the child theme, but because they’re more than 1 subdirectory below the main theme directory, they are not automatically loaded by WP.

    Any suggestions on how to override parent template files? I’ve been messing around with hooks and trying to figure out how to override the atp_shortcodes function in my child functions.php file (for the file above), but I haven’t had any luck.

    I did notice that in the parent functions.php file it mentions that it sets the file path based on whether the options framework is in a parent or child theme (starting line 95), but that doesn’t actually seem to be the case – it always returns the template directory, not the stylesheet directory (which would be the child theme). And copying the entire framework directory over to my child theme (and modifying the parent functions.php file to use the stylesheet directory as the path) seems to really defeat the purpose of being able to make tweaks to just a couple of framework files.

    2014-07-07 at 3:05 pm
    #4594
    Fem
    Keymaster
    • Topics: 2
    • Replies: 5215
    • Total posts: 5217
    • Post count: 6003

    We will look into the problem and see if that can be possible to make the things work out with the child themes if you need to alter the files from the parent theme.

    Meanwhile you can get it resolved from this http://codex.wordpress.org/Child_Themes#Referencing_.2F_Including_Files_in_Your_Child_Theme

    • This reply was modified 12 years, 2 months ago by Fem. Reason: Added link to the sample file for editing child theme
    2014-07-18 at 5:14 pm
    #4726
    Fem
    Keymaster
    • Topics: 2
    • Replies: 5215
    • Total posts: 5217
    • Post count: 6003

    Open the functions.php file in the child theme and then add the following code as shown below and then place the shortcode file according to your requirement in sub directory and make sure you set the correct path in the functions.php

    require_once ( get_stylesheet_directory() . '/framework/shortcode/foodmenu.php');
    

    After that in the parent theme and in the child theme shortcodes which you wish customize you need to wrap the code in as shown below as it has to be nested within the compaitbility function for child theme supports.

    if(!function_exists('menutype_menuspecial')){
    	function menutype_menuspecial ($atts, $content = null,$code) 
    	.....
    	.....
    	}
    }

    If you get confused or stuck at altering the code then please feel free to contact us via Skype and we will be there to assist you for adding this shortcode…

    • This reply was modified 12 years, 1 month ago by Fem.

You must be logged in to reply to this topic.