{"id":7178850,"date":"2016-03-16T19:44:47","date_gmt":"2016-03-16T19:44:47","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/trying-to-get-child-theme-working\/"},"modified":"2016-08-31T14:46:04","modified_gmt":"2016-08-31T14:46:04","slug":"trying-to-get-child-theme-working","status":"publish","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/trying-to-get-child-theme-working\/","title":{"rendered":"Trying to get child theme working"},"content":{"rendered":"<p>I&#8217;m trying to get a child theme working. It seems to do OK with the following in the functions.php file:<\/p>\n<p>&lt;?php<br \/>\nadd_action( &#8216;wp_enqueue_scripts&#8217;, &#8216;theme_enqueue_styles&#8217; );<br \/>\nfunction theme_enqueue_styles() {<br \/>\n    wp_enqueue_style( &#8216;parent-style&#8217;, get_template_directory_uri() . &#8216;\/style.css&#8217; );<\/p>\n<p>}<br \/>\n?&gt;<\/p>\n<p>But then when I add the code from my customizr functions.php file, then it doesn&#8217;t work. Below is the child functions.php code I&#8217;m trying. Any suggestions?<\/p>\n<p>Thanks,<br \/>\nSam<\/p>\n<p>&lt;?php<br \/>\nadd_action( &#8216;wp_enqueue_scripts&#8217;, &#8216;theme_enqueue_styles&#8217; );<br \/>\nfunction theme_enqueue_styles() {<br \/>\n    wp_enqueue_style( &#8216;parent-style&#8217;, get_template_directory_uri() . &#8216;\/style.css&#8217; );<\/p>\n<p>}<\/p>\n<p>add_filter( &#8216;get_comment_author_link&#8217;, &#8216;rv_remove_comment_author_link&#8217;, 10, 3 );<br \/>\nfunction rv_remove_comment_author_link( $return, $author, $comment_ID ) {<br \/>\n\treturn $author;<br \/>\n}<\/p>\n<p>add_filter( &#8216;tc_default_widgets&#8217; , &#8216;add_featured_page_widget&#8217; );<br \/>\nfunction add_featured_page_widget( $defaults ) {<br \/>\n\t$defaults[&#8216;fp_widgets&#8217;] = array(<br \/>\n                    &#8216;name&#8217;                 =&gt; __( &#8216;Featured Pages Widget&#8217; , &#8216;customizr&#8217; ),<br \/>\n                    &#8216;description&#8217;          =&gt; __( &#8216;Above the featured pages area on home&#8217; , &#8216;customizr&#8217; )<br \/>\n\t);<br \/>\n    return $defaults;<br \/>\n}<\/p>\n<p>add_action(&#8216;__before_fp&#8217; , &#8216;display_my_fp_widget&#8217;);<br \/>\nfunction display_my_fp_widget() {<br \/>\n    dynamic_sidebar(&#8216;fp_widgets&#8217;);<br \/>\n}<\/p>\n<p>\/\/ As of 3.1.10, Customizr doesn&#8217;t output an html5 form.<br \/>\nadd_theme_support( &#8216;html5&#8217;, array( &#8216;search-form&#8217; ) );<br \/>\nadd_filter(&#8216;wp_nav_menu_items&#8217;, &#8216;add_search_form_to_menu&#8217;, 10, 2);<br \/>\nfunction add_search_form_to_menu($items, $args) {<br \/>\n  \/\/ If this isn&#8217;t the main navbar menu, do nothing<br \/>\n  if( !($args-&gt;theme_location == &#8216;main&#8217;) ) \/\/ with Customizr Pro 1.2+ and Cusomizr 3.4+ you can chose to display the saerch box to the secondary menu, just replacing &#8216;main&#8217; with &#8216;secondary&#8217;<br \/>\n    return $items;<br \/>\n  \/\/ On main menu: put styling around search and append it to the menu items<br \/>\n  return $items . &#8216;&lt;li class=&#8221;my-nav-menu-search&#8221;&gt;&#8217; . get_search_form(false) . &#8221;;<br \/>\n}<\/p>\n<p>\/\/make it open affiliate link immediately if amazon<br \/>\nremove_action (&#8216;woocommerce_before_shop_loop_item&#8217;, &#8216;woocommerce_template_loop_product_link_open&#8217;, 10);<br \/>\nadd_action (&#8216;woocommerce_before_shop_loop_item&#8217;, &#8216;my_link_open&#8217;, 10);<br \/>\nfunction my_link_open() {<br \/>\n  global $product;<br \/>\nif( $product-&gt;is_type( &#8216;external&#8217; ) ){<br \/>\n$producturl = $product-&gt;get_product_url();<br \/>\n$position1 = stripos($producturl, &#8216;amazon&#8217;);<br \/>\n$position2 = stripos($producturl, &#8216;redirectAmzASIN&#8217;);<br \/>\nif ($position1 === false and $position2 === false) {<br \/>\n  \/\/ no # in sku so not an affiliate product<br \/>\n  $url = get_the_permalink();<br \/>\n} else {<br \/>\n  \/\/ must be an affiliate product<br \/>\n  $url = $product-&gt;get_product_url();<br \/>\n}<br \/>\n}<br \/>\nelse {<br \/>\n$url = get_the_permalink();<br \/>\n}<br \/>\necho &#8216;<a href=\"' . $url . '\">&#8216;;<br \/>\n}<\/p>\n<p>\/\/add javascript to certain pages<br \/>\nfunction wpb_adding_scripts() {<br \/>\n       wp_register_script(&#8216;HeightComparisonTool&#8217;, get_template_directory_uri() . &#8216;\/js\/HeightComparisonTool.js&#8217;,&#8221;,&#8217;1.1&#8242;, true);<br \/>\n       wp_register_script(&#8216;GetHeightArray&#8217;, get_template_directory_uri() . &#8216;\/js\/GetHeightArray.js&#8217;,&#8221;,&#8217;1.1&#8242;, true);<br \/>\n       if(is_single( &#8216;height-comparison-tool-celebrity-height-difference&#8217; )) {<br \/>\n          wp_enqueue_script(&#8216;HeightComparisonTool&#8217;);<br \/>\n          wp_enqueue_script(&#8216;GetHeightArray&#8217;);<br \/>\n       }<br \/>\n       if(is_page( &#8216;javascript-testing-2-2&#8217; )) {<br \/>\n          wp_enqueue_script(&#8216;HeightComparisonTool&#8217;);<br \/>\n          wp_enqueue_script(&#8216;GetHeightArray&#8217;);<br \/>\n       }<br \/>\n}<br \/>\nadd_action( &#8216;wp_enqueue_scripts&#8217;, &#8216;wpb_adding_scripts&#8217; );<\/p>\n<p>\/\/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<br \/>\nadd_action( &#8216;wp_footer&#8217;, &#8216;b5f_on_load_script&#8217; );<br \/>\nfunction b5f_on_load_script()<br \/>\n{<br \/>\n    \/\/Not our page, do nothing<br \/>\n    if( !is_single(&#8216;height-comparison-tool-celebrity-height-difference&#8217;) and !is_page(&#8216;javascript-testing-2-2&#8217;))<br \/>\n        return;<br \/>\n    ?&gt;<\/p>\n<p>    &lt;script type=&#8221;text\/javascript&#8221;&gt;<br \/>\n        window.onload = function() {<br \/>\nvar hashParams = window.location.hash.substr(1).split(&#8216;?&#8217;); \/\/ substr(1) to remove the <code>#<\/code><br \/>\nif(window.location.href.indexOf(&#8216;#&#8217;) != -1){ \/\/ No additional info, do nothing<br \/>\nfor(var i = 0; i &lt; hashParams.length; i++){<br \/>\n    var p = hashParams[i].split(&#8216;=&#8217;);<br \/>\n    document.getElementById(p[0]).value = decodeURIComponent(p[1]);<br \/>\n}<br \/>\n}<br \/>\nLoad(&#8220;Page&#8221;);<br \/>\n}<br \/>\n    &lt;\/script&gt;<\/p>\n<p>    &lt;?php<br \/>\n};<\/a><\/p>\n","protected":false},"template":"","class_list":["post-7178850","topic","type-topic","status-publish","hentry"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/7178850","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/7178850\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=7178850"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}