Tag Info

New answers tagged

0

Your code should be in an action callback function: function wpse186202_enqueue_scripts(){ wp_enqueue_script( 'stats', get_stylesheet_directory_uri() .'/js/t5-demo.js' , array( 'jquery' ), '1.0.0', true ); $categories = implode( ', ', wp_list_pluck( get_the_category( get_the_ID() ), 'name' ) ); $datatoBePassed = array( 'author' => ...


1

Unfortunately wp_localize_script() casts all scalars (simple types) in the passed-in array to strings (and then runs html_entity_decode() on them?!), so the casts mentioned by the answer you quote & @TheDeadMedic will get stringified "1"/"" if boolean, and number strings if ints, which won't work with javascript plugins that demand exact values. A way ...



Top 50 recent answers are included