I'm working in a child theme, In my-page-template.php
I have :
//...
$id_curr= 5;
wp_localize_script('my_js', 'ajaxload', array('post_id' => $id_curr));
In my_js.js
I have an AJAX call :
$.ajax({
//...
type: 'post',
data: {
action: 'ajax_load',
post_id: ajaxload.post_id
}
})
Now in functions.php
, I want to edit/update ajaxload.post_id
. Is there a way to do that? If I try re-calling wp_localize_script()
with the same $name
as shown below, will this work?
$id_new=8;
wp_localize_script('my_js', 'ajaxload', array('post_id' => $id_new));
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire