• Resolved Pratham

    (@pratham2003)


    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.

    1. Currency Exchange
    2. Currency
    3. Exchange

    The targets for all these keywords are different posts.

    For example, in the current version, most likely if I had entered the keyword Currency first, then on a content where the words Currency Exchange exist together, there is a chance that Currency and Exchange are linked separately. Some people might naturally want Currency Exchange to be given priority and linked first.

    For the same, could you modify the sorting order of getRules query to add ORDER 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 of Order 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.

    • This topic was modified 1 year, 5 months ago by Pratham.
    • This topic was modified 1 year, 5 months ago by Pratham.
Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Support markilj

    (@markilj)

    Thank you for contacting us.

    I see, does these keywords 1->3 are set in one post? or are they set in different posts? one post for each keyword?

    Currently, the setting https://i.imgur.com/zkzPCGO.png only sort the keywords per post, and not globally, so when the keywords 1->3 are only set in Post A, then it should link from “Currency Exchange”, but if the keywords are set on different posts, it is currently a limitation of the plugin.

    Can I ask about this?

    For the same, could you modify the sorting order of?getRules?query to add?ORDER 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 );
    

    I see you have tried to change the code, however, this part is only for outputting links generated from the link index table. It may seem to have fixed the issue in your case, but to avoid any conflicts with the index generation process, the keyword order should be resolved in the functions where we build our links.

    Currently, the global keyword priority is a current limitation of our plugin, but we have that on our pipeline for future implementations, we just can give any specific dates for this yet.

    Thank you

    Thread Starter Pratham

    (@pratham2003)

    I see, does these keywords 1->3 are set in one post? or are they set in different posts? one post for each keyword?

    Set in different posts.

    Currently, the setting?https://i.imgur.com/zkzPCGO.png?only sort the keywords per post, and not globally, so when the keywords 1->3 are only set in Post A, then it should link from “Currency Exchange”, but if the keywords are set on different posts, it is currently a limitation of the plugin.

    Exactly, when I initially read the setting, it was not apparent that the setting was not global until I tried it out against this particular case of keywords in different articles.

    I see you have tried to change the code, however, this part is only for outputting links generated from the link index table. It may seem to have fixed the issue in your case, but to avoid any conflicts with the index generation process, the keyword order should be resolved in the functions where we build our links.

    Currently, the global keyword priority is a current limitation of our plugin, but we have that on our pipeline for future implementations, we just can give any specific dates for this yet.

    That’s ok for us for the time being; but from your plugin’s perspective the plugin needs to give flexibility and meet some standards. A WP filter hook that allows devs to modify the array of keywords found for a specific post before they are used by the interlink process (e.g. allow devs to re-order it, or modify it) might help.

    This seems like a plugin that I can recommend to others for performance reasons ?? … I had used SEO Smart Links in the past (years ago) and was aware of it’s performance limitations with a large set of keywords. I had the same thought of creating an index to find which words are found in the current article that can be linked to greatly reduce the number of search & replace actions the plugin has to do for a given article on-the-fly.

    Plugin Support markilj

    (@markilj)

    I see, thank you for your feedback. We will discuss this improvements internally and implement if approved.

    Thank you

    Thread Starter Pratham

    (@pratham2003)

    getRules only works within a set of keywords for a given target but not on the list of all keywords across all the targets/rules. This was coincidentally working earlier because of the order in which I had added the keywords across different targets/articles.

    I made another change in the following file to sort the whole ruleset array on the basis of keyword/pattern length in descending order for my own personal purpose.
    File: wp-content\plugins\internal-links-premium\core\indexstrategy\indexstrategy.php

        /**
         * Sorts the ruleset by pattern length
         *
         * @param  object $a
         * @param  object $b
         * @return int
         */
        private function sortByPatternLength($a, $b) {
            return strlen($b->pattern) - strlen($a->pattern);
        }
        public function setLinkRules($link_rules)
        {
            $this->link_rules = $link_rules;
    +       usort($this->link_rules->ruleset, array($this, "sortByPatternLength"));
        }

    I have not seen any side-effects so far, please let me know if your team anticipates any critical issues with this kind of approach.

    If these features/controls can be built into the plugin later, it would be great.

    Plugin Support markilj

    (@markilj)

    getRules?only works within a set of keywords for a given target but not on the list of all keywords across all the targets/rules. This was coincidentally working earlier because of the order in which I had added the keywords across different targets/articles.

    I see yes you are correct, as we mentioned before it might work to some extent but will not necessarily sort/order keyword linking globally.

    We would need to dive deeper into this, but for now, if it works for you, I don’t see any issues with it, and we appreciate you sharing this with us.

    However, we have that on our pipeline for future implementations, we just can’t give any specific dates for this yet, but if we do we will update you.

    Thank you

    Plugin Support markilj

    (@markilj)

    As we have not heard from you in a while, we are closing the thread. Please feel free to get back in contact if you need further support.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Link the longer keywords (by characters) first’ is closed to new replies.