Saved Post Meta Array Returns as String
In the end it was a plugin and my code conflicting with each other. Both were saving my post_meta. Resulting in odd behavior of my code and functionality of retrieving the data.
In the end it was a plugin and my code conflicting with each other. Both were saving my post_meta. Resulting in odd behavior of my code and functionality of retrieving the data.
Textareas behave quite different to text inputs in the browser rendering engine. I cannot figure out the use case of a single line textarea without scroll bars. If you want to copy the default text input behaviour to all effects, what is wrong with using a simple input type=”text” instead for your custom field? If … Read more
$terms = get_terms( array( ‘taxonomy’ => ‘category’, ‘hide_empty’ => false, ) ); $sort = array(); //loop to list through all category foreach ( $terms as $term ) { $id = $term->ID; $name = $term->name; $args = array( ‘post_type’ => ‘post’, ‘category’ => $name, ); $query = new WP_Query( $args ); $sum = 0; if ($query->have_posts() … Read more
Okay I think I have it, you need to add a matching filter to attachment_fields_to_save to save the new field (say as post meta to the attachment.) add_filter( ‘attachment_fields_to_save’, ‘save_some_custom_field’, 10, 2 ); function save_some_custom_field($post, $attachment) { $attachid = $post[‘ID’]; // yes this is actually an array here update_post_meta($attachid,’someCustom’,$attachment[‘someCustom’]); } Then you would add to … Read more
Thanks guys.I did it with WP_Meta_Query (https://codex.wordpress.org/Class_Reference/WP_Meta_Query) Solution: <?php $query = new WP_Query( array( ‘meta_key’ => ‘j4cob_yaz_ayarlar_show_on_slider_’, ‘meta_value’ => ‘show-on-slider’, ‘posts_per_page’ => 6 ) ); ?> <?php if ( $query->have_posts() ) : while ( $query->have_posts() ) : $query->the_post(); ?> . Loop . <?php endwhile; wp_reset_postdata(); else : ?> <p><?php _e( ‘Sorry, no posts matched your … Read more
It should be the same. WP’s _meta functions handle serialisation for you.
Check if you have any white space below your code. You might have a “Japanese” white space Character. Anything else I can think of? I need 50 rep points to comment on this topic. Make sure to use unicode File transfers from Windows.
You can get images with foreach loop but first you have to print_r($images) and then get the value of the array something like this $images[‘image’] or $images[‘src’] or $images[‘url’] etc. But first check is there any record where you are getting get_sub_field(‘image’) all images. <?php if ( $images = get_sub_field(‘image’) ) : print_r($images); foreach($images as … Read more
There are a few different ways you could achieve this. The most obvious one would be to use two existing image fields- are you already using Title, caption, alt text and description? If not, these are available, and you could simply add some code to your template to use (say) the caption as the link … Read more
Retrieving and inserting data in custom fields