[wp-hackers] Can't find where <p> and <br /> tags are comingfrom
Steve Taylor
steve at sltaylor.co.uk
Sun Aug 5 13:14:36 UTC 2012
WordPress does automatically add <p> and <br> tags to anything that
goes through the the_content filter (i.e. if you output a post's
content with the the_content() template tag). You can avoid that in
particular instances by doing something like this:
remove_filter( 'the_content', 'wpautop' );
the_content();
add_filter( 'the_content', 'wpautop' );
However, I can't see use of the_content() in your code - it all seems
to be running through the Zend_Gdata_Photos class.
I got stuck once in a similar situation, and for the <br> tags,
there's a simple CSS workaround. If you can isolate the tag that wraps
the area where you don't want <br> tags, just add something like:
#wrapper br { display: none; }
Not sure about those stray <p> tags though...
On 4 August 2012 01:03, Diana K. C <dianakac at gmail.com> wrote:
> Thanks Will,
>
> Pardon, but you say compress it, like the whole code in a single line?!
>
> I removed the tags on output ("\n \t") but still the code outputs with
> breaks and html tags.
>
>
> ----- Original Message ----- From: "William P. Davis" <will.davis at gmail.com>
> To: <wp-hackers at lists.automattic.com>
> Sent: Friday, August 03, 2012 8:49 PM
> Subject: Re: [wp-hackers] Can't find where <p> and <br /> tags are
> comingfrom
>
>
>
>> 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
>> _______________________________________________
>> wp-hackers mailing list
>> wp-hackers at lists.automattic.com
>> http://lists.automattic.com/mailman/listinfo/wp-hackers
>
>
> _______________________________________________
> 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