Trying to get child theme working
-
I’m trying to get a child theme working. It seems to do OK with the following in the functions.php file:
<?php
add_action( ‘wp_enqueue_scripts’, ‘theme_enqueue_styles’ );
function theme_enqueue_styles() {
wp_enqueue_style( ‘parent-style’, get_template_directory_uri() . ‘/style.css’ );}
?>But then when I add the code from my customizr functions.php file, then it doesn’t work. Below is the child functions.php code I’m trying. Any suggestions?
Thanks,
Sam<?php
add_action( ‘wp_enqueue_scripts’, ‘theme_enqueue_styles’ );
function theme_enqueue_styles() {
wp_enqueue_style( ‘parent-style’, get_template_directory_uri() . ‘/style.css’ );}
add_filter( ‘get_comment_author_link’, ‘rv_remove_comment_author_link’, 10, 3 );
function rv_remove_comment_author_link( $return, $author, $comment_ID ) {
return $author;
}add_filter( ‘tc_default_widgets’ , ‘add_featured_page_widget’ );
function add_featured_page_widget( $defaults ) {
$defaults[‘fp_widgets’] = array(
‘name’ => __( ‘Featured Pages Widget’ , ‘customizr’ ),
‘description’ => __( ‘Above the featured pages area on home’ , ‘customizr’ )
);
return $defaults;
}add_action(‘__before_fp’ , ‘display_my_fp_widget’);
function display_my_fp_widget() {
dynamic_sidebar(‘fp_widgets’);
}// As of 3.1.10, Customizr doesn’t output an html5 form.
add_theme_support( ‘html5’, array( ‘search-form’ ) );
add_filter(‘wp_nav_menu_items’, ‘add_search_form_to_menu’, 10, 2);
function add_search_form_to_menu($items, $args) {
// If this isn’t the main navbar menu, do nothing
if( !($args->theme_location == ‘main’) ) // with Customizr Pro 1.2+ and Cusomizr 3.4+ you can chose to display the saerch box to the secondary menu, just replacing ‘main’ with ‘secondary’
return $items;
// On main menu: put styling around search and append it to the menu items
return $items . ‘<li class=”my-nav-menu-search”>’ . get_search_form(false) . ”;
}//make it open affiliate link immediately if amazon
remove_action (‘woocommerce_before_shop_loop_item’, ‘woocommerce_template_loop_product_link_open’, 10);
add_action (‘woocommerce_before_shop_loop_item’, ‘my_link_open’, 10);
function my_link_open() {
global $product;
if( $product->is_type( ‘external’ ) ){
$producturl = $product->get_product_url();
$position1 = stripos($producturl, ‘amazon’);
$position2 = stripos($producturl, ‘redirectAmzASIN’);
if ($position1 === false and $position2 === false) {
// no # in sku so not an affiliate product
$url = get_the_permalink();
} else {
// must be an affiliate product
$url = $product->get_product_url();
}
}
else {
$url = get_the_permalink();
}
echo ‘‘;
}//add javascript to certain pages
function wpb_adding_scripts() {
wp_register_script(‘HeightComparisonTool’, get_template_directory_uri() . ‘/js/HeightComparisonTool.js’,”,’1.1′, true);
wp_register_script(‘GetHeightArray’, get_template_directory_uri() . ‘/js/GetHeightArray.js’,”,’1.1′, true);
if(is_single( ‘height-comparison-tool-celebrity-height-difference’ )) {
wp_enqueue_script(‘HeightComparisonTool’);
wp_enqueue_script(‘GetHeightArray’);
}
if(is_page( ‘javascript-testing-2-2’ )) {
wp_enqueue_script(‘HeightComparisonTool’);
wp_enqueue_script(‘GetHeightArray’);
}
}
add_action( ‘wp_enqueue_scripts’, ‘wpb_adding_scripts’ );//run javascript when a certain page loads, the javascript being run checks the url for queries and populates corresponding html input and run the update
add_action( ‘wp_footer’, ‘b5f_on_load_script’ );
function b5f_on_load_script()
{
//Not our page, do nothing
if( !is_single(‘height-comparison-tool-celebrity-height-difference’) and !is_page(‘javascript-testing-2-2’))
return;
?><script type=”text/javascript”>
window.onload = function() {
var hashParams = window.location.hash.substr(1).split(‘?’); // substr(1) to remove the#
if(window.location.href.indexOf(‘#’) != -1){ // No additional info, do nothing
for(var i = 0; i < hashParams.length; i++){
var p = hashParams[i].split(‘=’);
document.getElementById(p[0]).value = decodeURIComponent(p[1]);
}
}
Load(“Page”);
}
</script><?php
};
- The topic ‘Trying to get child theme working’ is closed to new replies.