Answer the question
In order to leave comments, you need to log in
Why does json decode return NULL?
$demoids = json_encode(['111','222','333' ],JSON_UNESCAPED_UNICODE);
update_post_meta(get_the_id(), 'media_shortcode_', $demoids);
$demotext = [
'title' => ' Some testing text lorem ipsum ... ',
];
update_post_meta(get_the_id(), 'media_shortcode_111', $demotext);
$get_box_data = get_post_meta( get_the_id(), 'demoids ', true );
//тут уже NULL $get_box_data, но мне надо что бы сюда выводило поле title шорткодов, которые исопльзую // дальше в цикле
$meta_box_ids = json_decode($get_box_data);
foreach ($meta_box_ids as $key => $value) {
if( $box_data = get_post_meta( get_the_id(), 'media_shortcode_'.$value, true ) ){
?>
<input type='text' id='' name='id[""]' size='46' value='<?php echo $box_data["title"];?>' />
<?php
}
}
$get_box_data
what am I doing wrong?
Answer the question
In order to leave comments, you need to log in
I would venture to suggest that get_post_meta does not find data by the key - 'demoids' , because there are keys 'media_shortcode_' and 'media_shortcode_111'
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question