• mildlyhotpeppers

    (@mildlyhotpeppers)


    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="https://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

    (@mildlyhotpeppers)

    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="https://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 aalt=”____”`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?

    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.