Change post value in WordPress

In order to add a new value and keep the previous values, you need to use add_post_meta() instead of update_post_meta(): $post_id = get_the_ID(); $new_post_desc=”the new value here”; // add_post_meta() add a new field with the same name // and keeps previous values on the database add_post_meta( $post_id, ‘post_desc’, $new_post_desc ); Then, you can use get_post_custom_values() … Read more

Display custom image field in user profile

Check out the documentation for ACF image fields: https://www.advancedcustomfields.com/resources/image/ When you use get_field on an image field, it looks like it returns the ID for the image, not a URL. This might have been different in a previous version of ACF. I think something like this might work: $image = get_field(‘user_avatar’, $user->ID’); $size=”full”; // (thumbnail, … Read more

ACF Field, hide taxonomy title and image when no nothing selected in post

Seems the your post doesn’t attach any taxonomy. So just try to replace your code with this: <?php global $post; $tax = ‘directory_features’; $terms = get_the_terms($post,$tax); if ( $terms && ! is_wp_error( $terms ) ){ foreach( $terms as $term ) { $term_link = get_term_link( $term ); $image = get_field(‘svcta_favorites_image’,$term); if( $term->count > 0 ) { … Read more

advanced custom fields if field has value show main div [closed]

Please try below and let me know if any query. <?php if( get_field(‘packaging_details’) || get_field(‘port’) || get_field(‘lead_time’)): ?> <div class=”prd-overview-list”> <h3>Packaging & Delivery</h3> <ul> <?php if( get_field(‘packaging_details’) ): ?><li><p>Packaging Details</p> <p><span><?php the_field( ‘packaging_details’ ); ?></span></p></li><?php endif; ?> <?php if( get_field(‘port’) ): ?><li><p>Port</p> <p><span><?php the_field( ‘port’ ); ?></span></p></li><?php endif; ?> <?php if( get_field(‘lead_time’) ): ?><li><p>Lead Time</p> … Read more

Create Shortcode for php code in functions.php

If your code works fine then do this in function.php <?php add_shortcode( ‘custom_name’, ‘footag_func’ ); function footag_func( $atts ) { $html=””; $posts = get_field(‘related_posts’, false, false); $loop = new WP_Query(array(‘post_type’ => ‘post’, ‘posts_per_page’ => 3, ‘post__in’ => $posts, ‘post_status’ => ‘publish’, ‘orderby’ => ‘post__in’, ‘order’ => ‘ASC’ )); if($loop->have_posts()) { $html .= ‘<div class=”rel-posts”>’; while … Read more