WordPress.org

Ready to get started?Download WordPress

Forums

SEO Smart Links
SEO Smart Links Settings Faulty (7 posts)

  1. SammyJayJay
    Member
    Posted 1 year ago #

    I am using seo smart links and have the settings set to t allow links to self, and also limited to just one link of the same url... BUT some of my posts are showing links pointing to itself and some even have more than one....

    For example: see my page http://homeremedieslog.com/health-topics/hair-care/hair-growth/remedies-4/ and notice the links "vitamins to grow hair" and "hair growth remedies" both are made automatically by seo smart links and they both point to that same page even tho the settings are set for this not to happen..there should be no links pointing to itself and certainly not 2!!!

    Can anybody explain what is going on here please????

    Thanks

    http://wordpress.org/extend/plugins/seo-automatic-links/

  2. Web2Guru
    Member
    Posted 1 year ago #

    I ham having the same issue. Looking through the code, I found out that the setting only works to stop it from linking the page title to the same page.

    I.E. - if the page title is "Home Remedies" then it will not link the words "Home Remedies" on that page back to itself.

    No solution yet, just wanted to explain what was happening. I'm looking for a way to mod the plugin so it also doesn't link custom keywords to their respective pages.

  3. Web2Guru
    Member
    Posted 1 year ago #

    I take that back, I found where it is supposed to not link the text if it would link to itself. But I found the problem, working on fixing it now.

    It has to do with whitespace around the links and keywords. Quick solution is to remove all spaces around custom keywords and their urls.

    I.E.
    change
    Badan si Badun, http://belajar.indonesiamengajar.org/2012/09/badan-si-badun-alat-peraga-anatomi-tubuh-manusia/
    to
    Badan si Badun,http://belajar.indonesiamengajar.org/2012/09/badan-si-badun-alat-peraga-anatomi-tubuh-manusia/

    This also affects using multiple keywords per line, the link will include the space

    E.G.
    if you add Home Remedies as a keyword:
    Badan si Badun, Home Remedies, http://belajar.indonesiamengajar.org/2012/09/badan-si-badun-alat-peraga-anatomi-tubuh-manusia/
    and it is in the text, it would come out as:
    <a href="http://belajar.indonesiamengajar.org/2012/09/badan-si-badun-alat-peraga-anatomi-tubuh-manusia/"> Home Remedies</a>

    Working on adding some trim functions everywhere so we don't have this problem.

  4. Web2Guru
    Member
    Posted 1 year ago #

    In seo-links.php, starting at line 145 there is an if-else block inside a foreach loop that builds the array that holds the keywords and their respective urls. Add a couple of trim and str_replace functions to get things working properly, four of them as shown below, marked by the /*MOD*/ comments at the end of the lines:

    if($options['customkey_preventduplicatelink'] == TRUE) {  //Prevent duplicate links for grouped custom keywords
    
    				$line = trim($line);
    				$lastDelimiterPos=strrpos($line, ',');
    				$url = trim(substr($line, $lastDelimiterPos + 1 )); /*MOD*/
    				$keywords = substr($line, 0, $lastDelimiterPos);
    				$keywords = str_replace(', ', ',', $keywords); /*MOD*/
    
    				if(!empty($keywords) && !empty($url)){
    					$kw_array[$keywords] = $url;
    				}
    
    				$keywords='';
    				$url='';
    
    			} else {  //Old custom keywords behaviour
    
    			$chunks = array_map('trim', explode(",", $line));
    			$total_chuncks = count($chunks);
    			if($total_chuncks > 2) {
    				$i = 0;
    				$url = trim($chunks[$total_chuncks-1]); /*MOD*/
    				while($i < $total_chuncks-1) {
    					if (!empty($chunks[$i])) $kw_array[$chunks[$i]] = $url;
    						$i++;
    					}
    				} else {
    					list($keyword, $url) = array_map('trim', explode(",", $line, 2));
    					$keywords = str_replace(', ', ',', $keywords); /*MOD*/
    					if (!empty($keyword)) $kw_array[$keyword] = $url;
    				}
    
    			}

    I'm not positive the last two are needed since it does some trimming already, but my implementation is not using that part of the code (I chose to prevent duplicates), so I have not tested it.

  5. Web2Guru
    Member
    Posted 1 year ago #

    The code is not very well tabbed to be easy to read, here is a reformatted version, with /*MOD*/ indicators tabbed further out too:

    if($options['customkey_preventduplicatelink'] == TRUE) {  //Prevent duplicate links for grouped custom keywords
    
    	$line = trim($line);
    	$lastDelimiterPos=strrpos($line, ',');
    	$url = trim(substr($line, $lastDelimiterPos + 1 )); 			/*MOD*/
    	$keywords = substr($line, 0, $lastDelimiterPos);
    	$keywords = str_replace(', ', ',', $keywords); 				/*MOD*/
    
    	if(!empty($keywords) && !empty($url)){
    		$kw_array[$keywords] = $url;
    	}
    
    	$keywords='';
    	$url='';
    
    } else {  //Old custom keywords behaviour
    
    	$chunks = array_map('trim', explode(",", $line));
    	$total_chuncks = count($chunks);
    	if($total_chuncks > 2) {
    		$i = 0;
    		$url = trim($chunks[$total_chuncks-1]); 			/*MOD*/
    		while($i < $total_chuncks-1) {
    			if (!empty($chunks[$i])) $kw_array[$chunks[$i]] = $url;
    			$i++;
    		}
    	} else {
    		list($keyword, $url) = array_map('trim', explode(",", $line, 2));
    		$keywords = str_replace(', ', ',', $keywords); 			/*MOD*/
    		if (!empty($keyword)) $kw_array[$keyword] = $url;
    	}
    
    }
  6. SammyJayJay
    Member
    Posted 1 year ago #

    Hi..

    Thanks a lot!

    I just removed the spaces in the keywords set-up as you suggested in your quick fix.. and that has worked.

    But thanks for making the new code, I am sure it will be helpful for everybody having this problem.

    I assume that applying the new code.. will mean that links will not point to themselves no matter if there is a space or not in the link set-up.

  7. Web2Guru
    Member
    Posted 1 year ago #

    That is correct, spaces or not, it works with the code changes.

    Now if I can get it working in excerpts, I will be happy!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic