[wp-hackers] Can't find where <p> and <br /> tags are coming from
William P. Davis
will.davis at gmail.com
Fri Aug 3 23:49:37 UTC 2012
WordPress automatically adds p and be tags to the content before you echo it. To get around that, either make your code into a shortcode (preferable) or remove all line breaks from your code.
Will
Sent from my BlackBerry
-----Original Message-----
From: "Diana K. C" <dianakac at gmail.com>
Sender: wp-hackers-bounces at lists.automattic.com
Date: Fri, 3 Aug 2012 20:46:51
To: <wp-hackers at lists.automattic.com>
Reply-To: wp-hackers at lists.automattic.com
Subject: [wp-hackers] Can't find where <p> and <br /> tags are coming from
I needed to hardcode a plugin that retrieves Picasa Album, it works ok but don't know why P e BR tags are appearing, I tried to strip_tags, trim etc and can't get rid of them. Echoing works but then gets out before anything else in site as always :(
I think is something wrong in php, but maybe something to do with xml?! Thanks for any help.
The bit that outputs code I changed a bit is:
$html_gallery = '<ul class="gallery-list row">'."\n";
foreach ($feed as $entry) {
$title = $entry->getTitle();
$summary = $entry->getSummary();
$stuff = $entry->getMediaGroup()->getContent();
$url = $stuff[0]->getUrl();
$thumbnail = $entry->getMediaGroup()->getThumbnail();
$tags = $entry->getMediaGroup()->getKeywords();
$size = $entry->getGphotoSize();
$height = $entry->getGphotoHeight();
$width = $entry->getGphotoWidth();
$html_gallery .= "\n \t".'<li class="gallery-item"><a href="'.$url.'" class="lightbox"><figure><img class="imgpicasa" src="'.$thumbnail[2]->url.'" width="'.$thumbnail[1]->width.'" height="'.$thumbnail[1]->height.'"/><figcaption></figcaption></figure></a></li>'; //SOMETHING WRONG HERE?
}
$html_gallery .= '</ul>';
$content = $html_gallery.$content;
return strip_tags($content,'<ul><li><a><figure><figcaption><img>');
}
The wrong output (<br/> and <p> breaking layout :( ):
<li class="gallery-item"><a href="http://lh6.ggpht.com/-C1JJV9zcwr8/TVms7N1oktI/AAAAAAAAAss/wFdr1BpCPys/DSCN1215.JPG" class="lightbox"><br />
<figure><img class="imgpicasa" src="http://lh6.ggpht.com/-C1JJV9zcwr8/TVms7N1oktI/AAAAAAAAAss/wFdr1BpCPys/s288/DSCN1215.JPG" width="144" height="108"/><br />
<figcaption></figcaption>
</figure>
<p></a></li>
FULL PLUGIN CODE BEFORE MOD: http://pastebin.com/Zfasaz1J
_______________________________________________
wp-hackers mailing list
wp-hackers at lists.automattic.com
http://lists.automattic.com/mailman/listinfo/wp-hackers
More information about the wp-hackers
mailing list