• I am using wp_localize_script() to send my posts to JS in order to do a custom html css and js layout but the thing is it’s giving me a critical error so I am not sure what have I done wrong.
    Below is my php function.

    function enqueue_script() {
        wp_enqueue_script( 'script',  plugin_dir_url( __FILE__ ) . 'script.js' );       
       
        wp_localize_script('script', 'script_variables', array(
            'posts' => __(get_posts())
        ));          
    }
    add_action( 'wp_enqueue_scripts', 'enqueue_script');
  • The topic ‘Polylang with wp_localize_script()’ is closed to new replies.