Notifications
Clear all

Search by topic title returns all posts from a topic whose title matches the search

2 Posts
2 Users
0 Reactions
150 Views
Posts: 5
Topic starter
(@gianttoe)
Active Member
Joined: 4 weeks ago

Is there a function to fix this in the settings?


1 Reply
Sofy
Posts: 5572
 Sofy
Admin
(@sofy)
Support Team
Joined: 8 years ago

Hi,

Please use the hook code below; 

add_filter( 'wpforo_search_sql', function( $sql, $args ){
    if( wpfval($args, 'type') === 'titles-only' ){
       $sql = str_replace( ' WHERE ', ' WHERE p.`is_first_post` = 1 AND ', $sql );
    }
    return $sql;
}, 10 ,2 );

Helpful article: https://www.wpbeginner.com/plugins/how-to-easily-add-custom-code-in-wordpress-without-breaking-your-site/


Reply