Support » Plugin: Contextual Related Posts » Exclude keywords

  • Resolved tea23hah

    (@tea23hah)


    Hi there,

    great plugin!

    Is there a way to exclude certain words and symbols from the matching algorithm?

    For example if you have a website covering apples, where every title contains the word “apple”, it would be nice if you could exclude the word “apple” from the matching algorithm so the output is more relevant. I know that right now it would probably still look for other words matching, so “apple tree” would still show posts with “apple tree” over “apple juice”, but if I could exclude “apple”, it would only show posts about “apple tree” instead of filling up the remaining spots with any post title containing the word “apple”.

    Same for websites that include the date in the title of most of their articles. The algorithm picks two very relevant posts and then just fills the remaining spots with any title containing “2020”.

    Hope that makes sense, thanks for your help!!

Viewing 1 replies (of 1 total)
  • Plugin Author Ajay

    (@ajay)

    Hi,

    Unfortunately not. The mySQL matching algorithm prioritises both words and then the single words – which what you saw.
    I’ve not yet found a way to dynamically add stop words – I think a boolean mode search might work, but that drastically reduces the number of search results.

    Are you comfortable editing the php files to give it a test?

    https://github.com/WebberZone/contextual-related-posts/blob/v2.8.0/includes/main-query.php#L412

    Line to be replaced:

    
    
    $match = $wpdb->prepare( ' AND MATCH (' . $match_fields . ') AGAINST (%s) IN BOOLEAN MODE ', $stuff );
    
    
Viewing 1 replies (of 1 total)
  • The topic ‘Exclude keywords’ is closed to new replies.