Delete images in posts for specific author
-
I’m trying to edit the single.php page to remove images from the content but only for a specific user. I’ve found past employees have used copyrighted images and been hit with bills for them more than once. I’ve moved all the posts to a single user and now want to simply not show images for that author.
I’ve found that the following code works to remove images from the content:
ob_start(); the_content('Read the full post',true); $postOutput = preg_replace('/<img[^>]+./','', ob_get_contents()); ob_end_clean(); echo $postOutput;
But all attempts to have it used only for the one author either removes the content entirely or breaks the site.
Any assistance would be greatly appreciated.
If it helps, the current content is pulled in with:
<?php get_template_part( 'content' ); ?>
Regards.
Dave
- The topic ‘Delete images in posts for specific author’ is closed to new replies.