Else If statement for ACF [closed]

You’re mixing curly brackets and another syntax. This should help: <?php if(get_field(‘hero_video’, ‘option’) ) { $headervideo = get_field( ‘hero_video’, ‘option’ ); echo ‘<div class=”headervideo”>’ . $headervideo . ‘</div>’; } elseif ( get_field( ‘hero_upload’, ‘options’ ) ) { $headerupload = get_field( ‘hero_upload’, ‘option’ ); echo ‘<div class=”hero-video” data-vide-bg=”mp4: ‘ . $headerupload . ‘” data-vide-options=”loop: true, muted: … Read more

ACF: using two loops, the_field returns field content from another loop

I’m not fun of helper functions so I would write it like this: $args=array( ‘post_type’ => ‘post’, ‘posts_per_page’ => ’20’, ‘post_status’ => ‘publish’, ‘order’=>’DESC’, ‘orderby’=>’ID’, ); $query = new WP_Query( $args ); if ( $query->have_posts() ) { while ( $query->have_posts() ) { $query->the_post(); $current_id = $post->ID; echo the_field(‘field1’, $current_id); } wp_reset_postdata(); } else { // … Read more

WooCommerce Custom Tab with ACF Repeater Field

I believe you need to use get_sub_field() for the repeater field (designer_achievements) and get_field() for its parent. Please take a look at the ACF documentation for the Repeater field’s subfield. You will also need to use a have_rows() loop, as noted in the documentation. if( have_rows(‘parent_field’) ): while( have_rows(‘parent_field’) ) : the_row(); $value = get_sub_field(‘sub_field’); … Read more

ACF Custom field not showing in Timber Taxonomy page

In your PHP file… $context[‘topicTax’] = Timber::get_terms(‘topic’); Timber::render(‘my-template.twig’, $context); … is the correct structure. The problem is that WP’s get_terms returns “dumb” objects that don’t have methods for retrieving ACF info. If you still run into issues, verify that those objects are Timber\Terms rather than WP_Term Also, if you’re looking for the more active forum: … Read more

Query string order by custom field

The query_posts is only useful when you actually know what you are doing. Base on the info you provide this should work for you : $the_query = new WP_Query(array( ‘post_type’ => ‘your_cpt’, ‘posts_per_page’ => -1,//get them all ‘meta_key’ => ‘field_4’, ‘orderby’ => ‘meta_value’, ‘order’ => ‘DESC’ )); ?> <?php if( $the_query->have_posts() ): ?> <ul> <?php … Read more

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