ACF page while loop breaks footer while loop

Looks like you need to add ‘option’ to your footer the_sub_field() calls: <p><a href=”https://wordpress.stackexchange.com/questions/307577/<?php the_sub_field(“footer_link’, ‘option’); ?>”><?php the_sub_field(‘footer_link_name’, ‘option’); ?></a></p> var_dump() is used to dump a variable, not a string, so you would need to do something like var_dump($test) for that line to work. You are probably getting errors and warnings in your PHP log … Read more

How can I add multiple ‘tax_query’ arrays via a loop?

OK, I have no idea how and why your code should work… It has nothing in common with correct PHP syntax… But it’s pretty good pseudo-code, so I think I can guess, what you wanted to achieve… $tax_query = array(); if ( have_rows(‘category_taxonomies’) ) { while ( have_rows(‘category_taxonomies’) ) { the_row(); $tax_query[] = array( ‘taxonomy’ … Read more

Loop through custom fields with similar label / common chars in label

You display data in loop, so all item have the same ID div id=”demo”. Add some suffix to make them unique. For example: $lang = substr($field[‘name’], strpos($field[‘name’], “_”); echo ‘<button data-toggle=”collapse” data-target=”#demo-‘. $lang .'”> ….’; echo ‘<div id=”demo-‘. $lang .'” class=”collapse”> …</div>’ Edit Audio doesn’t work inside the collapse panel because key $name never meets … Read more

Custom query based on meta key – Reduce three states to two in results?

This can be done by providing a “default” value to the ORDER BY statement. Try adding this before your call new WP_Query($args);: $setDefaultOrderby = function($statement) { return str_replace(‘wp_postmeta.meta_value’, “COALESCE(wp_postmeta.meta_value, ‘false’)”, $statement); }; add_filter(‘posts_orderby’, $setDefaultOrderby); and this after it: remove_filter(‘posts_orderby’, $setDefaultOrderby); Change the ‘false’ with whatever the default value is that you need. I am using … Read more

Getting value from Advanced Custom Fields [closed]

You are trying to use get_field_object, which isn’t correct. What you should be using is get_field() or the_field(). Example get_field(): $value = get_field( “locations” ); if( $value ) { echo $value; } else { echo ’empty’; } Example the_field(): <p><?php the_field(‘locations’); ?></p> Note: ACF has great documentation, you should look it over.

How to loop only categories without posts (+ show category featured image with acf) [closed]

Well, in WP the word “loop” is mainly related to posts. It’s easier to say that you want to display categories. All you have to do is to get them using get_categories function and display them. <?php $categories = get_categories( array( ‘orderby’ => ‘name’, ‘order’ => ‘ASC’ ) ); if ( ! empty( $categories ) … Read more

Gutenberg on an ACF options page

Create a page named as your archive, add blocks there. In archive-name.php please add: <?php get_header(); $page_id = get_post( 57 ); $page = apply_filters( ‘the_content’, $page->post_content ); echo $page; ?> <?php get_footer(); Replace ’57’ with your page ID. Now you can manage content of archive page directly from Pages.