Stripping images in Wordpress
- Started
- Last post
- 13 Responses
- Anders0
Hmm.. this code(gets only the images):
$images =& get_children( 'post_type=attachment&post_mime... . $post->ID );
foreach( $images as $imageID => $imagePost )
echo wp_get_attachment_image($imageID... 'thumbnail', false);doesn't link to the attachments page, how to include that?
- Anders0
I remember using a php function for drupal that worked perfectly with wordpress, so try it out. Fake it till you make it.
- janne760
I know what Anders is on.. at least a bit.. :)
- Anders0
Thanks, acescence. That's kind of beautiful discovering somebody had the same problem :-)
- janne760
anyone know how to do this in Textpattern, without the need for handcoding it in every post? (read: clients!)
- acescence0
here you go:
- Anders0
Actually got it working with this;
echo strip_tags(nl2br(get_the_content('')),"<strong><strong><em><em><a>");But that includes only what I specify in there, is there a way of including every possible future markup that I might use in a post besides those who applies to the images?
It would be easier if it was the other way around; exclude the <img>
- acescence0
that is a tricky one and i don't have a simple answer.
you can try playing around with get_the_content() instead of the_content(), which is the content before wp applies all the formatting filters to it
- Anders0
OK, so this gets only the images:
$images =& get_children( 'post_type=attachment&post_mime... . $post->ID );
foreach( $images as $imageID => $imagePost )
echo wp_get_attachment_image($imageID... 'thumbnail', false);How do I get the rest of the content into the other div, with images being the only exception?
- acescence0
you can get all the images in a post separate from text by using get_children
http://codex.wordpress.org/Funct…
http://codex.wordpress.org/Templ…
- Anders0
A simple example
<div id="images">images</div>
<div id="text">text</div>Isn't this possible in single.php somehow?
- 7point340
fuck you and your underhanded scheme to get me to read your thread!
- http://www-student.c…Anders
- hahaha, fucking bears7point34
- Anders
Kinky headline.
Problem:
I want my images displayed in another div than the the rest of my content.
I'm going to use the strip_tag function, but how to do this in single.php?