March 7, 2016 at 12:54 pm
I need to modify functions.php to change the wpml language switcher behavior. I believe that I’ll need to use a child theme so that future pinnacle premium updates don’t overwrite my modifications.
I reviewed the Kadence documentation, created new style.css and function.php files, and uploaded them to a new pinnacle-premium-child directory. I must of missed something, because I white screen came up when I went into Live Preview mode. My style.css and functions.php are below.
Was I supposed to do something different with styles.css? The wordpress documentation indicates that another step is required for the style sheet. It states that the correct method of enqueuing the parent theme stylesheet is to add a wp_enqueue_scripts action and use wp_enqueue_style() in your child theme’s functions.php.
Style.css
/*
Theme Name: pinnacle premium child
Theme URI: *Login to see link
Description: pinnacle premium child theme
Author: Dean Hill
Author URI: *Login to see link
Template: pinnacle_premium
Version: 1.0.0
License: GNU General Public License v2 or later
License URI: *Login to see link
Tags: light, dark, two-columns, right-sidebar, responsive-layout, accessibility-ready
Text Domain: pinnacle_premium_child
*/
functions.php
<?php // Opening PHP tag - nothing should be before this, not even whitespace
/*
* Custom Language Switcher Code - makes inactive language display instead
* of active
*/
function new_nav_menu_items($items,$args) {
if (function_exists('icl_get_languages')) {
$languages = icl_get_languages('skip_missing=0');
if(1 < count($languages)){
foreach($languages as $l){
if(!$l['active']){
$items = $items.'<li class="menu-item"><a href="'.$l['url'].'">'.$l['native_name'].'</a></li>';
}
}
}
}
return $items;
}
add_filter( 'wp_nav_menu_items', 'new_nav_menu_items',10,2 );