• Resolved Nguyen Le

    (@nguyenrom)


    Hi ACF Extended,

    I have used Terms in Advanced link to get product taxonomy, but ACF Extended did not return thumbnail object.

    Do you think adding custom hook to below code is good?

    function format_value($value, $post_id, $field){
            
            // get value
            $value = $this->get_value($value);
            
            // Custom hook
            $value = apply_filters("bluecoral_acf_extended_hook", $value);
    
            // clean
            acfe_unset($value, 'type');
            acfe_unset($value, 'post');
            acfe_unset($value, 'term');
            acfe_unset($value, 'url_title');
    
            return $value;
            
        }

    Thank you

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Konrad Chmielewski

    (@hwk-fr)

    Hello,

    Thanks for the feedback!

    There is no need for additional filter here. You can retrieve the unformatted value of any ACF Field using by passing a parameter in your get_field(). See documentation.

    For example, here the formatted value of the Advanced Link:

    get_field('my_advanced_link', 270);
    
    array(
        "title"  => "Text",
        "url"    => "https://www.domain.com/category-1",
        "target" => "0",
    )
    

    Here is the unformatted value of the Advanced Link. Note the false at the end:

    get_field('my_advanced_link', 270, false);
    
    array(
        "type"   => "term",
        "term"   => "1",
        "title"  => "Text",
        "target" => "0",
    )
    

    With the term id you can retrieve the Term Object using get_term() (See documentation), and then construct your thumbnail.

    Hope it helps!

    Have a nice day!

    Regards.

    Thread Starter Nguyen Le

    (@nguyenrom)

    Thank @hwk-fr so much

    Your plugin is awesome ??

    Plugin Author Konrad Chmielewski

    (@hwk-fr)

    You’re welcome!

    PS: Thanks for the nice review ??

    Have a nice day!

    Regards.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Get object in Advanced link’ is closed to new replies.