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’, ), ));

Post Object Filter by Custom Field, not title (ACF)

There’s another filter for the post_object: acf/fields/post_object/result, that lets you customise the result (text) displayed for each option in the post object field. Try something like this: function my_post_object_result( $title, $post, $field, $post_id ) { /* Get whatever value you want here e.g. */ $short_title= get_field(‘short_title’, $post->ID); /* do any other processing you might want … Read more

WP Custom Fields Metabox Disappears – ACF plugin issue [closed]

ACF 5.6+ intentionally removes the custom fields metabox to improve performance when loading posts. To display the metabox, add this to functions.php in your theme: add_filter( ‘acf/settings/remove_wp_meta_box’, ‘__return_false’ ); In addition to the above code, make sure that the custom fields metabox is enabled in Screen Options at the top of a post, and that … Read more

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

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