Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › get_post_meta get only the parent site results not the child site. › Reply To: get_post_meta get only the parent site results not the child site.
January 13, 2016 at 3:08 pm
#7306
Hi!
Since you are executing get_post_meta in the template files, it’s executed withing the current blogs context, which is in your case the parent site.
Instead of making this change in the template files, you should rather use a filter function which is executed within the search process, when the blog switching is still active – thus calling the get_post_meta in the correct context.
In your case you can access the “date” field after the result post-process with the ‘asp_result_date_after_prostproc’ filter like so:
add_filter( 'asp_result_date_after_prostproc', 'asp_change_post_date', 1, 3 );
function asp_change_post_date( $date, $post_id, $search_id ) {
$meta = get_post_meta( $post_id, "my_meta_key", true );
if ( !empty($meta) ) return $meta;
return $date;
}
Best,Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)



