Make wp_localize_script() work properly

August 2, 2010

wp_localize_script($handle, $object_name, $l10n); For example: $myvars = array(‘value’ => ‘one’); wp_localize_script(‘my-handle’, ‘myVars’, $myvars); The above code won’t do anything unless you enqueue a script with the same handle before it, like this: wp_enqueue_script(‘my-handle’, ‘path-to-js-file.js’); $myvars = array(‘value’ => ‘one’); wp_localize_script(‘my-handle’, ‘myVars’, $myvars); This code will be inserted into your page: /* <![CDATA[ */ var myVars [...]

wp_list_comments() will append an end tag to your comment

July 29, 2010

On every call to your call back from wp_list_comments(), there will be an end tag appended, this tag can be either </li> or </div> depending on your style parameter. Therefore, in your call back function, don’t put your own end tag there. For example, my call back function was like this: function custom_comments($comment, $args, $depth) [...]