• First of all, thank you for this plugin!

    I have a post with the text “lorem ipsum SEO services lorem ipsum”

    Now, If I add a new link with the keywords “SEO” and “SEO services”, the plugin will only replace “SEO” with the link but not “SEO services”.

    Is there a way to replace the longest keyword the plugin finds?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author webraketen

    (@webraketen)

    Hey FraT,

    it normally should work like you expect it. So the replacement should prefer “SEO services” over “SEO”, if you have both active.

    As we do not support self-linking atm: Could you check if your keyword “SEO services” does link to the same page, where it appears?

    Thanks

    Thread Starter FraT

    (@frat)

    Hi Webraketen,
    I can replicate the issue with the code below:

    
    <?php 
    use html_changer\HtmlChanger;
    
    require 'vendor/autoload.php';
    
    $text = 'lorem ipsum SEO services SEO services lorem ipsum';
    
    $search = array (
      'seo' => array (
        'caseInsensitive' => true,
        'wordBoundary' => false,
        'value' => 5,
        'group' => '53',
        'maxCount' => 1,
      ),
      'seo services' => array (
        'caseInsensitive' => true,
        'wordBoundary' => false,
        'value' => 5,
        'group' => '53',
        'maxCount' => 1,
      ),
    );
    
    $htmlChanger = new HtmlChanger($text, [
        'search' => $search,
        'ignore' => [
                'a', // links
                'h1', 'h2', 'h3', 'h4', 'h5', 'h6', // headlines
            ]
    ]);
    
    $htmlChanger->replace(function($text, $value){
    	echo $text;
    });

    The aspected result of the echo is “SEO services” but it outputs “SEO”. Removing the ‘group’ fields or increasing the ‘maxCount’ the output is “SEO services”.

    I hope this helps.

    Plugin Author webraketen

    (@webraketen)

    We’ll have a look at that. Thanks a lot!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Keywords and keyphrases’ is closed to new replies.