Site icon Hip-Hop Website Design and Development

How can I modify the question by including to the present question?

I’ve two capabilities that each modify the question, nonetheless the latest one I’ve created, I want to add this modification alongside the earlier one (i.e. not overwriting it).

The concept is that this operate would run final, and basically be added as an ‘AND’ meta_query. However how can I get it to do this?

// Order any 'featured' psychics to be on the prime
operate pr_psychic_featured_pinned($question) {

    if(!is_admin() && $query->is_post_type_archive('psychic')) {

        // Get present meta question
        $meta_query = $query->get('meta_query');

        // If there isn't any meta question when this filter runs,
        // it must be initialised as an empty array
        if(!$meta_query) {
            $meta_query = [];
        }

        // Append our meta question
        $meta_query = [
            'key'       => 'psychic_featured',
            'orderby'   => 'meta_value',
            'order'     => 'DESC'
        ];
        $query->set('meta_query', $meta_query);

    }

    return $question;

}
add_action('pre_get_posts', 'pr_psychic_featured_pinned');