WP Rest endpoint with custom post type and ACF Fields

Advanced custom fields uses get_field() function to retrieve the fields. So, all you have to do is to retrieve them by using: $field = get_field(‘field_name’, $post->ID, ‘format_value’); for each of your fields in the loop. You can read this page for more information. Questions about plugins are off-topic here, That’s why your question haven’t receive … Read more

Inconsistent behavior from number_format

Seems like the function you using is the the_field function from of ACF which is a function that outputs a string so the formatting number_formatt dosent effect the output. This code: <?php echo number_format(the_field(‘price’)); ?> The echo does not really print anything, the function the_fields prints the output, that’s the reason the number_format function doesn’t … Read more

Using pre_get_posts for meta value of LIKE comparison on ACF repeater sub field

You need to add Wildcards to your meta_value. Change $query->set(‘meta_query’, array( array( ‘meta_key’ => ‘test_repeater_%_test_sub_field’, ‘meta_value’ => $search, ‘compare’ => ‘LIKE’, ), )); To $query->set(‘meta_query’, array( array( ‘meta_key’ => ‘test_repeater_%_test_sub_field’, ‘meta_value’ => ‘%’.$search.’%’, ‘compare’ => ‘LIKE’, ), ));

How I can check if get_theme_mod is in header or a template part

I tried if ( ! did_action( ‘get_header’ ) ) but doesn’t seem to work. Try again, but this way: add_filter( ‘theme_mod_understrap_container_type’, ‘override_container_type’ ); function override_container_type( $value ) { if ( did_action( ‘get_header’ ) && ! did_action( ‘get_footer’ ) ) { if ( get_field(‘container_type’) !== ‘inherit’ ){ return get_field(‘container_type’); } } // For header.php and footer.php … Read more

Insert Commas into ACF number field

You need to ‘hook’ your function to a valid hook. Your add_action call is not doing anything, because it is not a proper call to a hook.. See the docs https://developer.wordpress.org/reference/functions/add_action/ for add_action. Your function is the second parameter of the add_action hook. The first parameter is ‘where’ to hook into WordPress. If you want … Read more

Acf Pro repeater field returns null [closed]

I’ve just solved this issue thanks to the Avanced WordPress group in Facebook (https://www.facebook.com/groups/advancedwp/). It was actually a mistake I had made: I had a query before the custom fields and it had to be reset. This is the working snippet: <?php // WP_Query arguments $args = array ( ‘post_type’ => ‘post’, ‘posts_per_page’ => ‘4’, … Read more

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