Can’t get “has_sub_field()” to work in a conditional [closed]

You need to use the has_sub_field() method inside an if() statement. I’ve only included the affected code below to highlight the specific changes required. if (has_sub_field(‘vimeo_id’)): // Added if() // … endif; You also need to a use the get_sub_field() function here as opposed to the has_sub_field() function: <iframe src=”https://player.vimeo.com/video/<?php echo get_sub_field(‘vimeo_id’); ?>”></iframe>

While loop with bootstrap [closed]

Try using the count variable to increment the loop. <div class=”panel-group” id=”accordion” role=”tablist” aria-multiselectable=”true”> <?php if(get_field(‘faq_general_ht’)): ?> <?php $count=0; ?> <?php while(has_sub_field(‘faq_general_ht’)): ?> <div class=”panel panel-default”> <div class=”panel-heading” role=”tab” id=”headingTwo”> <h4 class=”panel-title”> <?php echo ‘<a data-toggle=”collapse” data-parent=”#accordion” href=”#collapse’ .$count. ‘”aria-expanded=”true”>’ ?> <p><?php the_sub_field(‘faq_general_question_ht’) ?></p> </a> </h4> </div> <?php echo ‘<div id=”collapse’ .$count. ‘” class=”panel-collapse collapse” … Read more

Show only the future event (Advanced Custom Fields)

You need a meta query. There’s also documentation on ACF for querying dates. <?php $event = new WP_Query( array( ‘post_type’ => ‘gacr-event’, ‘posts_per_page’ => 5, ‘orderby’ => ‘meta_value_num’, ‘order’ => ‘DESC’, ‘meta_query’ => array( array( ‘key’ => ‘date’, ‘type’ => ‘NUMERIC’, // MySQL needs to treat date meta values as numbers ‘value’ => current_time( ‘Ymd’ … Read more

ACF: Querying relationship fields with Author

The users doesn’t have permalinks nor titles. They have author links and display names. Changed the code: <?php while ( have_posts() ) : the_post(); ?> <h2>Resturants</h2> <?php $resturants = get_users(array( // Changed from get_posts ‘fields’ => ‘all_with_meta’, // All with meta to get also display_name ‘meta_query’ => array( array( ‘key’ => ‘resturant’, // name of … Read more

ACF repeater field usage

Simply use get_sub_field(“session_speaker”); function to retrieve that data. As you’ve said this is a relational field, it will return an array of post objects according to the docs. In order to get data from each speaker, you need to loop through the resulting array. Example: $speakers = get_sub_field(“session_speaker”); if ($speakers && count($speakers)>0) { foreach ($speakers … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)