Hook to Use Field Befor Fallback
-
I’ll provide background below, but the TLDR is that I can’t find the right field/function to insert the post title at the <need_something_here> in the code below.
if ( ! function_exists( 'before_fallback_tagline_text' ) ) { /** * Add description meta tag with excerpt text. * * @return void */ function before_fallback_tagline_text( $value, $post_id, $field ) { // Check for banner image setting if ( empty( $value ) && 'tagline' === $field['name'] ) { // Retrieve thumbnail setting (As attachment ID) $fallback = get_post_meta( $post_id,<need_something_here>, true ); // Substitute the fallback for the missing mobile attachment if ( ! empty( $fallback ) ) $value = $fallback; } return $value; } } add_filter( 'acf/load_value', 'before_fallback_tagline_text', 99, 3 );
I’m working on a site that’s using ACF and Elementor. I need to create a hook that will insert a second field in between the chosen ACF and the fallback. (Hopefully I’m using those terms correctly.) In other words, in Elementor, you can say
- Display this ACF
- If it’s empty, display the designated fallback
What I’d like the hook to do is change that to
- Display this ACF
- If it’s empty, display field_xyz
- If that’s empty too, display the designated fallback
The code above works if ‘field_xyz’ is another ACF, but I can’t find the right thing to get it to use the post title as the second choice.
I also have a variation of the code for images (pretty much the same code, just different names). Here again, it works fine if both the first choice and second choice are ACF, but I can’t find the right thing to use the post thumbnail (aka featured image) as the second choice.
- The topic ‘Hook to Use Field Befor Fallback’ is closed to new replies.