Title: Filtering the_content();
Last modified: August 19, 2016

---

# Filtering the_content();

 *  [mildlyhotpeppers](https://wordpress.org/support/users/mildlyhotpeppers/)
 * (@mildlyhotpeppers)
 * [18 years, 3 months ago](https://wordpress.org/support/topic/filtering-the_content-1/)
 * Is there anyway I can “filter” the output of `the_content();`?
 * I run a web comic, and I was hoping to put a little box underneath the comic 
   for visitors to paste into a blog, a Myspace, etc, and it would basically be 
   the HTML code for an image. It would have to be not parsed by the browser, however,
   so it would look like
 * `<a href="<?php the_permalink(); ?>"><?php the_content(); ?></a><a href="http://
   mildlyhotpeppers.com">MildlyHotPeppers.com</a>`
 * (I hope this doesn’t get rendered. /edit – it seems like it did get rendered…
   to clarify the left angle brackets are actually & lt; without the space and the
   right angle brackets are & gt; without the space./)
 * Where I have `<?php the_content(); ?>`, however, I was hoping I could sort of
   filter the content. As of now, each post for as comic looks like `<img src=”___”
   alt=”___” / >
    `, and so I would like to get rid of the <p> tags and also replace
   the < with & lt; and the > with & gt; (I added spaces to they wouldn’t get parsed)
   so that the output of the php isn’t parsed as HTML.

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Thread Starter [mildlyhotpeppers](https://wordpress.org/support/users/mildlyhotpeppers/)
 * (@mildlyhotpeppers)
 * [18 years, 3 months ago](https://wordpress.org/support/topic/filtering-the_content-1/#post-696370)
 * I ended up just using javascript for that part, using the string.replace(); function.
   I made it replace “<p><” with “& lt;” and “></p>” with “& gt;”. The second part,
   however, isn’t as easy:
 * I wanted to also add an option to paste it into a forum, using the forum markup.
   So it would look like
 *     ```
       [URL="<?php the_permalink(); ?>"]
       <?php the_content(); ?>[/URL]
       [URL="http://www.mildlyhotpeppers.com/"]MildlyHotPeppers.com[URL]
       ```
   
 * And I need the resulting content to be in the format `[IMG]___________[/IMG]`.
   I would replace `<a href="` with `[IMG]`.
    Except this time I can’t just replace`
   > `with`[/IMG]`because there's still a`alt=”____”`somewhere in there. So I’d 
   have to use regular expressions to replace all of it, wouldn’t I?
 * I don’t know regex yet though…can anyone help?
 *  [kenleewrites](https://wordpress.org/support/users/kenleewrites/)
 * (@kenleewrites)
 * [17 years, 4 months ago](https://wordpress.org/support/topic/filtering-the_content-1/#post-696650)
 * how did you pass the contents of the_contents into the javascript? is it just
   like json?

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Filtering the_content();’ is closed to new replies.

## Tags

 * [filter](https://wordpress.org/support/topic-tag/filter/)
 * [the_content](https://wordpress.org/support/topic-tag/the_content/)

 * 2 replies
 * 2 participants
 * Last reply from: [kenleewrites](https://wordpress.org/support/users/kenleewrites/)
 * Last activity: [17 years, 4 months ago](https://wordpress.org/support/topic/filtering-the_content-1/#post-696650)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
