How to change any WordPress blog inner content link href by PHP code

WordPress Blog Inner Content Href Link change or update with PHP.

Firstly, go to includes directory in the WordPress theme folder below path

../blog/wp-content/themes/enfold/includes

in includes folder find

loop-index.php

Find $content_output PHP variable code around after 208 line of code you find

$content_output  =  '<div class="entry-content" '.avia_markup_helper(array('context' => 'entry_content','echo'=>false)).'>';
$content_output .=  $content;
$content_output .=  '</div>';

After that line, put PHP str_replace code. Below is our replace href link code

$content_output = str_replace('https://myfreeonlinetools.com/blog/','https://myfreeonlinetools.com/', $content_output);

$content_output = str_replace('https://myfreeonlinetools.com/guide/','https://myfreeonlinetools.com/', $content_output);

$content_output = str_replace('https://myfreeonlinetools.com/resouce/','https://myfreeonlinetools.com/', $content_output);

$content_output = str_replace('https://myfreeonlinetools.com/donote/','https://myfreeonlinetools.com/', $content_output);

You can use any where str replace but I used after used $content_output code.

and check hover on a link href will change with replace text.

str_replace

PHP str replace replace all or some characters with some other character in PHP string and this php function is binary-safe. Case sensitivities apply to this function. To replace something without regard to case.

Syntax:

str_replace(find,replace,string,count);

ref link : https://www.php.net/manual/en/function.str-replace.php