• Resolved elmersw

    (@elmersw)


    Hi,

    First of all: I just installed your plug-in and I think it’s great. Finally a filter plug-in with free support for custom meta fields. However, one of those custom meta fields contains a post-object. Fortunately the filter can handle an object as it can extract and display the ID of the related post. I would rather display the post_title than the ID. I guess that would require just a bit of coding. To avoid to break your code I would like to know what hook and variables to use. I found this topic:https://www.ads-software.com/support/topic/acf-select-field-support/

    Is this the hook I can use?

    BTW, I will definitely rate your plugin as soon I have completed the configuration ??

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author stepasyuk

    (@stepasyuk)

    Hello @elmersw

    Thank you for your warm words about the plugin. I’m glad to hear this.

    About your question – yes, exactly. This hook allows you to replace Post ID with Post title. In the example below my_post_object_meta_key is the Meta key (Field Name) used in ACF

    <?php
    
    add_filter( 'wpc_filter_post_meta_term_name', 'wpc_custom_term_name', 10, 2 );
    function wpc_custom_term_name( $term_name, $e_name ){
        // $e_name is meta key in our case
        // $term_name is term value stored in meta field in our case
        if( $e_name === 'my_post_object_meta_key' ){
            $term_name = get_the_title( $term_name );
        }
    
        return $term_name;
    }
    
    ?>

    I would be thankful for your review

    Thread Starter elmersw

    (@elmersw)

    I didn’t expect you would even supply the code. Got it working within a minute. Thanks a lot.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Custom field post object showing ID instead of title’ is closed to new replies.