How to get a custom post type archive paged when using a custom field for post sorting?

You shouldn’t be using a custom query for a post type archive page. Pagination being difficult is one of the reasons. If you want to change your post type archive to sort by a custom field, hook into pre_get_posts to modify the main query: function wpse_282839_post_type_order( $query ) { if ( ! is_admin() && $query->is_post_type_archive( … Read more

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