<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Flav36rs &#187; formatting</title>
	<atom:link href="http://flav36rs.com/tag/formatting/feed/" rel="self" type="application/rss+xml" />
	<link>http://flav36rs.com</link>
	<description>Just another technical blog</description>
	<lastBuildDate>Mon, 12 Sep 2011 16:56:36 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>WordPress: Prevent auto  tags in page content</title>
		<link>http://flav36rs.com/2010/08/07/wordpress-prevent-auto-br-tags-in-page-content/</link>
		<comments>http://flav36rs.com/2010/08/07/wordpress-prevent-auto-br-tags-in-page-content/#comments</comments>
		<pubDate>Sat, 07 Aug 2010 09:47:53 +0000</pubDate>
		<dc:creator>Steve</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[formatting]]></category>
		<category><![CDATA[wpautop]]></category>

		<guid isPermaLink="false">http://36flavours.com/?p=721</guid>
		<description><![CDATA[If you make use of some basic mark-up in your WordPress page content, you may have encountered an issue where &#60;br /&#62; tags are appearing where they shouldn&#8217;t and are affecting your theme layout. To prevent this happening but leave &#8230; <a href="http://flav36rs.com/2010/08/07/wordpress-prevent-auto-br-tags-in-page-content/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>If you make use of some basic mark-up in your WordPress page content, you may have encountered an issue where &lt;br /&gt; tags are appearing where they shouldn&#8217;t and are affecting your theme layout.</p>
<p>To prevent this happening but leave the auto conversion of double line-breaks into paragraph tags, I had a dig into the <a href="http://codex.wordpress.org/Function_Reference/wpautop" target="_blank">wpautop</a> function that runs before the content is outputted to the screen.<span id="more-721"></span></p>
<p>This function accepts two parameters, the first is the content to be formatted and the second determines whether to convert remaining line breaks into &lt;br /&gt; tags.</p>
<p>Because the wpautop filter is automatically applied to the content, we first need to remove that by adding the following to our functions.php file:</p>
<pre lang="php" escaped="true">remove_filter('the_content', 'wpautop');</pre>
<p>Then we must apply the formatting function again but this time set the the second parameter to false and prevent the additional &lt;br /&gt; tags appearing.</p>
<pre lang="php" escaped="true">function wpautopnobr($content) {
	return wpautop($content, false);
}
add_filter('the_content', 'wpautopnobr');</pre>
<p>This can be customised further by checking to see if we are on a page rather than a post and only applying the formatting if that is the case. The required code in it&#8217;s entirety is as follows:</p>
<pre lang="php" escaped="true">remove_filter('the_content', 'wpautop');
function wpautopnobr($content) {
	return wpautop($content, (is_page() ? true : false));
}
add_filter('the_content', 'wpautopnobr');</pre>
]]></content:encoded>
			<wfw:commentRss>http://flav36rs.com/2010/08/07/wordpress-prevent-auto-br-tags-in-page-content/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>WP &#8211; Add class name to first paragraph in blog post</title>
		<link>http://flav36rs.com/2009/08/20/wp-add-class-name-to-first-paragraph-in-blog-post/</link>
		<comments>http://flav36rs.com/2009/08/20/wp-add-class-name-to-first-paragraph-in-blog-post/#comments</comments>
		<pubDate>Thu, 20 Aug 2009 15:04:27 +0000</pubDate>
		<dc:creator>Steve</dc:creator>
				<category><![CDATA[Blogging]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[formatting]]></category>
		<category><![CDATA[function]]></category>

		<guid isPermaLink="false">http://36flavours.com/?p=273</guid>
		<description><![CDATA[When re-designing my blog I wanted to display the first paragraph of each blog post in bold text. A CSS3 selector could have been used, but wouldn&#8217;t work in older browsers such as IE6. Instead I decided to write a &#8230; <a href="http://flav36rs.com/2009/08/20/wp-add-class-name-to-first-paragraph-in-blog-post/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>When re-designing my blog I wanted to display the <strong>first paragraph</strong> of each blog post in <strong>bold text</strong>. A CSS3 selector could have been used, but wouldn&#8217;t work in older browsers such as <strong>IE6</strong>.</p>
<p>Instead I decided to write a very simple function to add a class name to the first paragraph by filtering the content, then setting the styles accordingly in my theme CSS file.<span id="more-273"></span></p>
<pre lang="php" escaped="true">function first_paragraph($content){
	return preg_replace('/&lt;p([^&gt;]+)?&gt;/', '&lt;p$1 class="first"&gt;', $content, 1);
}
add_filter('the_content', 'first_paragraph');</pre>
<p>By default this will append <em>class=&#8221;first&#8221;</em> to the first p tag in your post.</p>
<p>If you want to use this function on your own blog, just add it to your (or create a) <strong> functions.php</strong> file within your themes folder.</p>
]]></content:encoded>
			<wfw:commentRss>http://flav36rs.com/2009/08/20/wp-add-class-name-to-first-paragraph-in-blog-post/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>

