This website uses cookies to personalize your experience. By using this website you agree to our cookie policy.

Reply To: Linking result to custom field

#13212
mmmateommmateo
Participant

Thanks Ernest,

That didn’t solve the issue, but it helped point me in the right direction. To solve it, I had to use the ACF function get_field() vs get_post_meta(). This may be helpful to include in your documentation, in case other users are using ACF alongside your plugin.

[code]
add_filter( ‘asp_results’, ‘asp_custom_link_meta_results’, 1, 1 );

function asp_custom_link_meta_results( $results ) {

// Change this variable to whatever meta key you are using
$key = ‘attach_document’;

// Parse through each result item
foreach ($results as $k=>$v) {
$new_url = get_field($key, $v->id, true);

// Change only, if the meta is specified
if ($new_url != ”)
$results[$k]->link = $new_url;
}

return $results;
}
[/code]

Thanks again,

Mateo