WordPress.org

Ready to get started?Download WordPress

Forums

Advanced Custom Fields
Custom Field show something other than post_title (2 posts)

  1. psperkins
    Member
    Posted 5 months ago #

    I am wondering if there is a way to show something other than the post_title in the select field when displaying a list of items for a "page link" field (for instance).

    Is there a filter to change this?
    The issue I am having is I would like to show an event date as many events share same post_title so all I see in the select field is "post title" over and over again the same thing. I need a unique field to use here.

    If this is possible, or if there is a filter I can use that would be absolutely tremendous. Thank you for your time and your wonderfully useful time saving plugin.

    http://wordpress.org/plugins/advanced-custom-fields/

  2. psperkins
    Member
    Posted 5 months ago #

    aaaannnnddd..answered my own question. Well, sort of.

    I am able to get the value inserted if I use the "relationship" field type like so:

    function my_relationship_result( $result, $object, $field, $post )
    {
        // load a custom field from thie $object and show it in the $result
        $edate = get_post_meta($object->ID, '_event_start_date', true);
    
        // add post type to each result
        $result .= '[' . $edate .  ']';
    
        return $result;
    }
    
    add_filter('acf/fields/relationship/result/key=field_52d70c2b4887f', 'my_relationship_result', 10, 4);

    My question is now "is there any way to do this same thing with the 'page_link' field type? All I need is the url it seems wasteful to load the entire post object for just a link.

    Thanks again.

Reply

You must log in to post.

About this Plugin

About this Topic