How to convert custom fields to content

You can do this by using something similar <?php //Post we need to update $id = 37; $custom_field = get_post_meta( $id, ‘custom_field_key’, true ); // Update post 37 $mg_post = array( ‘ID’ => $id, ‘post_content’ => $custom_field, ); // Update the post into the database wp_update_post( $mg_post ); //Delete the custom field delete_post_meta( $id, ‘custom_field_key’ … Read more

Problem with adding custom CSS class to image in ACF Photo Gallery plugin [closed]

Try this code at the place where you want your gallery: <?php $images = acf_photo_gallery(‘gallery_images’, $post->ID); /// gallery_images to slug pola galeria w ACF if( count($images) ): foreach($images as $image): $full_image_url= $image[‘full_image_url’]; $class = get_field(‘gallery_images_class’, $id); echo ‘<img src=”‘.$image[‘full_image_url’].'” class=”‘.$class.'” >’; endforeach; endif; ?> Do try to check if ‘$id’ gives you the image/post id … Read more

Sum and count of custom field values

Thanks for your help guys. They didn’t quit work exactly, but I managed to get the result I needed by doing the following $reviewsNum = 0; $reviewsCount = 0; $argsSchema = array( ‘post_type’ => ‘reviews’, ‘posts_per_page’ => -1 ); $loopSchema = new WP_Query( $argsSchema ); $count_reviews = wp_count_posts( ‘reviews’ )->publish; while ( $loopSchema->have_posts() ) : … Read more