You get a bonus - 1 coin for daily activity. Now you have 1 coin

Remove hyperlinks in a WordPress post

Practice




remove hyperlinks in a wordpress post

Insert the php code below into the theme_functions.php file, which is stored in the folder yoursite.com/wp-content/themes/theme-name/functions/

Don't forget to comment it before inserting it into the file, so you'll understand later what you inserted.

Code to insert

/*function to remove links from images in news posts - when viewing the full text*/

add_filter( ‘the_content’, ‘link_remove_filter’ );

function link_remove_filter( $content ) {
$content =
preg_replace(
array('{]*> '{ wp-image-[0-9]*» />}'),
array(''),
$content
);
return $content;
}

the code doesn't work, and even if it does work, not always

put a stub in the template so the links don't trigger, for example something like this


yes, it's a bit hacky, but it works

Comments

To leave a comment

If you have any suggestion, idea, thanks or comment, feel free to write. We really value feedback and are glad to hear your opinion.
To reply

Lectures and tutorial on "Running server side scripts using PHP as an example (LAMP)"

Terms: Running server side scripts using PHP as an example (LAMP)