get_post_meta get only the parent site results not the child site.

Home Forums Product Support Forums Ajax Search Pro for WordPress Support get_post_meta get only the parent site results not the child site.

This topic contains 1 reply, has 2 voices, and was last updated by Ernest Marcinko Ernest Marcinko 8 years, 4 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • #7305


    We bought ‘Ajax Search Pro’ plugin and its working until we start them to customize the result.

    We are using ‘The Event Calendar’ plugin for event management. Here when user searching for events in ‘Ajax Search Pro’ plugin we want to show the event page (not the post date) along with event title.

    We followed the procedure as in by using the get_post_meta function. But that function only brought the results from parent site tables (ex: wp_postmeta) not the child site tables (ex: wp_2_postmeta).

    We experimented the same function for other plugins and it works fine. Can you please assist us to get this fixed?

    Ernest Marcinko
    Ernest Marcinko


    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;  
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.