How to query wordpress with array of meta_values?
How to query wordpress with array of meta_values?
How to query wordpress with array of meta_values?
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
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
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
After spending some days and testing lots of solutions, at last I have solved the problem using wordpress audio php function directly in code instead of using shortcode and do_shortcode() function. here you can find more detail and how to use it: https://codex.wordpress.org/Function_Reference/wp_audio_shortcode
Wrapping an unknown amount of posts inside separate HTML Containers during WP_Query loop
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
As we can see on the Codex, all strings produced in a Shortcode must be returned instead of echoing them.
Managed to get the custom field method to work, which saves alot of headache in the long run, solution was simple – <?php post_class(get_field(‘the-field’)); ?>
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