public function updateLinkInfo($results, $query)
    {
        $results = array_map(function ($result) {
            // Get post type
            $post_type = get_post_type($result['ID']);
            $obj = get_post_type_object($post_type);
            // Add post type to result info
            $result['info'] = '<strong>' . $obj->labels->singular_name . '</strong>';
            // Get post parents
            $ancestors = get_post_ancestors($result['ID']);
            $ancestors = array_reverse($ancestors);

            // Add post parents path to info string
            if (is_array($ancestors) && !empty($ancestors)) {
                $parent_string = implode(' / ', array_map(function ($ancestor) {
                  return get_the_title($ancestor);
                }, $ancestors)) . ' / '. $result['title'];

                $result['info'] = $result['info'] . ': ' . $parent_string;
            }

            return $result;
        }, $results);

        return $results;
    }
public function updateLinkInfo($results, $query)
    {
        $results = array_map(function ($result) {
            // Get post type
            $post_type = get_post_type($result['ID']);
            $obj = get_post_type_object($post_type);
            // Add post type to result info
            $result['info'] = '<strong>' . $obj->labels->singular_name . '</strong>';
            // Get post parents
            $ancestors = get_post_ancestors($result['ID']);
            $ancestors = array_reverse($ancestors);

            // Add post parents path to info string
            if (is_array($ancestors) && !empty($ancestors)) {
                $parent_string = implode(' / ', array_map(function ($ancestor) {
                  return get_the_title($ancestor);
                }, $ancestors)) . ' / '. $result['title'];

                $result['info'] = $result['info'] . ': ' . $parent_string;
            }

            return $result;
        }, $results);

        return $results;
    }
public function updateLinkInfo ( $ results , $ query ) { $ results = array_map ( function ( $ result ) { // Get post type $ post_type = get_post_type ( $ result [ 'ID' ] ) ; $ obj = get_post_type_object ( $ post_type ) ; // Add post type to result info $ result [ 'info' ] = '<strong>' . $ obj -> labels -> singular_name . '</strong>' ; // Get post parents $ ancestors = get_post_ancestors ( $ result [ 'ID' ] ) ; $ ancestors = array_reverse ( $ ancestors ) ; // Add post parents path to info string if ( is_array ( $ ancestors ) && ! empty ( $ ancestors ) ) { $ parent_string = implode ( ' / ' , array_map ( function ( $ ancestor ) { return get_the_title ( $ ancestor ) ; } , $ ancestors ) ) . ' / ' . $ result [ 'title' ] ; $ result [ 'info' ] = $ result [ 'info' ] . ': ' . $ parent_string ; } return $ result ; } , $ results ) ; return $ results ; }
Get the post type and its parents
@param  array $results An associative array of query results
@param  array $query   An array of WP_Query arguments
@return array
Get the post type and its parents