Feb
16
2009
Removing Images from a WordPress Post: Redux
I wanted to remove the images from a WordPress post to give me more control of how I could layout the design for the front page of a website. After doing some messing around and failing, I finally found a great post by Chris Shuld which had an amazing little piece of code that solved my problem. I just had to make a few modifications to it.
<?php $content = get_the_content(); $postOutput = preg_replace('/<img[^>]+./','', $content); echo $postOutput; ?> |
THANK YOU!!!! I have never commented on a blog, but this little piece of code kicked ass!
Hi. Your code really helps me! Just a question. It looks like displaying “plain” text. Do you know how can I get the html code in the content like p, a, h3, etc tags?
Just use the following:
wplistcategories(‘usedescfor_title=0′);
print("wp_list_categories('use_desc_for_title=0'); ");
Do i put this code in the page or in the functions?
I’m trying to use this with an excerpt function, here is what I have:
The excerpt never showed an image, but because of the image placement it didn’t show any text either.
Now it’s only showing the 1st letter of the post.
Take a look at this post:
http://bavotasan.com/tutorials/limiting-the-number-of-words-in-your-excerpt-or-content-in-wordpress/
where i must add the code? wp_config.php?
You can add that code directly to the file where you want to call the content.
Thank you!
No my search finaly ends.
I’m sorry, I send a comment about this subject and then see this page. thanks lot
Oh, your script is pretty useful ,Thank you so much!!:DDD
Perfect!! Thanks