Search results should include instrucror name

Home Forums Legacy Support Support queries Other issues Search results should include instrucror name

Tagged: ,

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #152152
    kaugurs
    Spectator
    Hi, Is it possible to include an instructors name to the TOP SEARCH BOX results? At the moment the search returns only course title results. Thanks!
    #152187
    Mark Morgan
    Spectator
    Yes, you can search courses by instructor name. Please enable the setting 'Navigation search as course search' to do this please go to wp-admin -> WPLMS-> Header  http://prntscr.com/j0mdeu Also add thge following php code in wplms-customizer plugin -> wplms-customizer.php file. Code: add_filter( 'posts_search', 'db_filter_authors_search' ); function db_filter_authors_search( $posts_search ) { // Don't modify the query at all if we're not on the search template // or if the LIKE is empty if ( !is_search() || empty( $posts_search ) ) return $posts_search; global $wpdb; // Get all of the users of the blog and see if the search query matches either // the display name or the user login add_filter( 'pre_user_query', 'db_filter_user_query' ); $search = sanitize_text_field( get_query_var( 's' ) ); $args = array( 'count_total' => false, 'search' => sprintf( '*%s*', $search ), 'search_fields' => array( 'display_name', 'user_login', ), 'fields' => 'ID', ); $matching_users = get_users( $args ); remove_filter( 'pre_user_query', 'db_filter_user_query' ); // Don't modify the query if there aren't any matching users if ( empty( $matching_users ) ) return $posts_search; // Take a slightly different approach than core where we want all of the posts from these authors $posts_search = str_replace( ')))', ")) OR ( {$wpdb->posts}.post_author IN (" . implode( ',', array_map( 'absint', $matching_users ) ) . ")))", $posts_search ); return $posts_search; }
Viewing 2 posts - 1 through 2 (of 2 total)
  • The topic ‘Search results should include instrucror name’ is closed to new replies.