Link the longer keywords (by characters) first
-
For example, I have the following keywords which target different target URLs.
e.g. Please assume that all the 3 keywords below target different posts.- Currency Exchange
- Currency
- Exchange
The targets for all these keywords are different posts.
For example, in the current version, most likely if I had entered the keywordCurrency
first, then on a content where the wordsCurrency Exchange
exist together, there is a chance thatCurrency
andExchange
are linked separately. Some people might naturally wantCurrency Exchange
to be given priority and linked first.
For the same, could you modify the sorting order ofgetRules
query to addORDER BY LENGTH(anchor) DESC
?The following example solves my issue.
$query = $wpdb->prepare( "SELECT * FROM " . $wpdb->prefix . self::ILJ_DATABASE_TABLE_LINKINDEX . " linkindex WHERE linkindex.link_from = %d AND linkindex.type_from = %s ORDER BY LENGTH(anchor) DESC", $id, $type );
Maybe it would be better to introduce a char_length and word_length field as well.
This could be done conditionally on the basis ofOrder for configured keywords while linking
setting. https://i.imgur.com/zkzPCGO.png (P.S. This setting name also seems a little misleading if we consider this case?)Please let me know if there are any questions or if I need to explain in a different way; or in case I missed/misunderstood something.
- The topic ‘Link the longer keywords (by characters) first’ is closed to new replies.