<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>LessThanWeb</title>
	
	<link>http://www.lessthanweb.com</link>
	<description>hand coded, clean and usable code</description>
	<lastBuildDate>Tue, 26 Mar 2013 09:25:24 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/LessThanWeb" /><feedburner:info uri="lessthanweb" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Get WordPress Page Excerpt</title>
		<link>http://feedproxy.google.com/~r/LessThanWeb/~3/ROgxHtl1los/get-wordpress-page-excerpt</link>
		<comments>http://www.lessthanweb.com/blog/get-wordpress-page-excerpt#comments</comments>
		<pubDate>Wed, 06 Feb 2013 11:32:11 +0000</pubDate>
		<dc:creator>Anze Stokelj</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[how to]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.lessthanweb.com/?p=235</guid>
		<description><![CDATA[Yesterday I wanted to show page excerpt using get_posts on front page of a theme and of course came to the problem because WordPress does not create page excerpts by default. So now what? Well the only way I could get page excerpt from a page is by using the excerpt field (not shown on [...]]]></description>
				<content:encoded><![CDATA[<p>Yesterday I wanted to show page excerpt using <a href="http://codex.wordpress.org/Template_Tags/get_posts" target="_blank">get_posts</a> on front page of a theme and of course came to the problem because WordPress does not create page excerpts by default.</p>
<p>So now what? Well the only way I could get page excerpt from a page is by using the excerpt field (not shown on page edit by default) or by automatically clean the content of the page, limit the number of words and output it.</p>
<p><span id="more-235"></span></p>
<h2>Manual Method</h2>
<p>Manual method means that you will have to enter page excerpt into excerpt field when adding new page or editing old one.</p>
<p>The way to get the excerpt field to the add new page simply put this code into functions.php file of your theme.</p>
<pre class="brush: php; title: ; notranslate">
// Init hook
add_action('init', 'my_custom_page_excerpt');

// Function that adds the excerpt field onto the add new page
function my_custom_page_excerpt()
{
    // Register excerpt feature for pages
    add_post_type_support('page', 'excerpt');
}
</pre>
<p>And that&#8217;s it for the manual method. Now when you add or edit a page and you will see the excerpt field (if you can&#8217;t see it, click on Screen Options and check the Excerpt checkbox).</p>
<h2>Automatic Method</h2>
<p>This method will get the page excerpt for each requested page on the fly without you having to add extra texts into extra input fields. Just the way I like it. :)</p>
<pre class="brush: php; title: ; notranslate">
function get_my_page_excerpt($page_id = 0, $word_limit = 55)
{
	// Stop here if page id is not set
	if ($page_id === 0)
	{
		return FALSE;
	}

	// Get content from page
	$page = get_posts(array(
	    'include' =&gt; $page_id,
	    'post_type' =&gt; 'page'
	));

	//	Get the page content, that is will all the shortcodes and HTML
	$content = $page[0]-&gt;post_content;

	//	Strip all the shortcodes from the post content
	$content = strip_shortcodes($content);

	//	CDATA
	$content = str_replace(']]&gt;', ']]&amp;gt;', $content);

	//	Strip all the HTML tags from the content
	$content = strip_tags($content);

	//	Separate words by space
	$words = explode(' ', $content, $word_limit + 1);

	//	Check if the content of the page is actually longer then the stripped content
	if(count($words) &gt; $word_limit)
	{
		//	Remove last array
		array_pop($words);

		//	Merge words from array to string
		$content = implode(' ', $words);

		//	Add at the end the ...
		$content .= '...';
	}

	//	Return page excerpt
	return $content;
}

echo get_my_page_excerpt(1101);
</pre>
<p>The above code will create page excerpt from page content just for one page. For my use, I use array to get page excerpt for a few pages with just one <a href="http://codex.wordpress.org/Template_Tags/get_posts" target="_blank">get_posts()</a> call. I removed the array option here but it&#8217;s simple to add it.</p>
<p>Do you know a better way of getting page excerpts? Let me know.</p>
<img src="http://feeds.feedburner.com/~r/LessThanWeb/~4/ROgxHtl1los" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.lessthanweb.com/blog/get-wordpress-page-excerpt/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.lessthanweb.com/blog/get-wordpress-page-excerpt</feedburner:origLink></item>
		<item>
		<title>LTW Content Shortcodes Plugin Released</title>
		<link>http://feedproxy.google.com/~r/LessThanWeb/~3/PwgGksCHDU8/ltw-content-shortcodes-plugin-released</link>
		<comments>http://www.lessthanweb.com/blog/ltw-content-shortcodes-plugin-released#comments</comments>
		<pubDate>Mon, 04 Feb 2013 10:22:49 +0000</pubDate>
		<dc:creator>Anze Stokelj</dc:creator>
				<category><![CDATA[Plugin]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.lessthanweb.com/?p=234</guid>
		<description><![CDATA[LTW Content Shortcodes is a plugin that will enable you to include tabs, buttons, columns and toggle elements into your content easily and quickly. Currently it support four shortcodes: tabs, buttons, columns and toggle. The reason I made this plugin is because I needed a simple and lightweight plugin that doesn&#8217;t have lots of options [...]]]></description>
				<content:encoded><![CDATA[<p>LTW Content Shortcodes is a plugin that will enable you to include tabs, buttons, columns and toggle elements into your content easily and quickly.</p>
<p>Currently it support four shortcodes: tabs, buttons, columns and toggle.</p>
<p>The reason I made this plugin is because I needed a simple and lightweight plugin that doesn&#8217;t have lots of options that are never used. Plus, most of the plugins I&#8217;ve tested have crappy code and are just bad. :)</p>
<p><span id="more-234"></span></p>
<p>For full details on the plugin, shortcodes and the options, <a title="Content Shortcodes" href="http://www.lessthanweb.com/wordpress-plugins/content-shortcodes">click here</a>.</p>
<img src="http://feeds.feedburner.com/~r/LessThanWeb/~4/PwgGksCHDU8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.lessthanweb.com/blog/ltw-content-shortcodes-plugin-released/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.lessthanweb.com/blog/ltw-content-shortcodes-plugin-released</feedburner:origLink></item>
		<item>
		<title>Boxy – New WordPress Theme Released</title>
		<link>http://feedproxy.google.com/~r/LessThanWeb/~3/ubn8xIP032U/boxy-new-wordpress-theme-released</link>
		<comments>http://www.lessthanweb.com/blog/boxy-new-wordpress-theme-released#comments</comments>
		<pubDate>Thu, 24 Jan 2013 11:08:22 +0000</pubDate>
		<dc:creator>Anze Stokelj</dc:creator>
				<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[theme]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.lessthanweb.com/?p=226</guid>
		<description><![CDATA[Boxy is a WordPress responsive theme that looks cool and modern on any device. Theme is packed with features and with the theme you will also get all the PSD files that were used to create this theme as well as a full working HTML version of the theme! For typography the theme uses two from Google [...]]]></description>
				<content:encoded><![CDATA[<p><a href="http://www.lessthanweb.com/wordpress-themes/boxy">Boxy</a> is a WordPress responsive theme that looks cool and modern on any device.</p>
<p>Theme is packed with features and with the theme you will also get all the PSD files that were used to create this theme as well as a full working HTML version of the theme!</p>
<p>For typography the theme uses two from <a href="http://www.google.com/webfonts">Google Fonts</a> which are available for free.</p>
<p>Here are some of the features:</p>
<p><span id="more-226"></span></p>
<ul>
<li>Custom menu</li>
<li>Custom background</li>
<li>Custom front page</li>
<li>Full-width and blog templates</li>
<li>3 sidebars (all pages, blog posts only and pages only)</li>
<li>SEO tools for blog posts, pages, tags and categories</li>
<li>Theme options</li>
<li>Support for Google Analytics</li>
<li>Support for Google and Bing ownership verifing</li>
<li>Support for Microformats and Google Plus profile</li>
<li>RTL ready</li>
<li>Translation ready with translation file included</li>
<li>Support for WordPress editor styles</li>
<li>Style support for Contact Form 7 plugin</li>
<li>Custom action and filter hooks</li>
</ul>
<p>Theme has included 4 shortcodes:</p>
<ul>
<li>Columns</li>
<li>Tabs</li>
<li>Toggle</li>
<li>Buttons</li>
</ul>
<p>Theme has 23 action and 6 filter hooks that you can use to extend the theme easily and quickly.</p>
<p>And comes with two integrated widgets, Extended Recent Comments and Extended Recent Posts.</p>
<p>Theme has a file structure that enables you to extend the functions of the theme without worrying<br />
of losing the updates you made when a new update of the theme is available.</p>
<p><a href="http://www.lessthanweb.com/wordpress-themes/boxy">Go and check it out.</a></p>
<img src="http://feeds.feedburner.com/~r/LessThanWeb/~4/ubn8xIP032U" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.lessthanweb.com/blog/boxy-new-wordpress-theme-released/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.lessthanweb.com/blog/boxy-new-wordpress-theme-released</feedburner:origLink></item>
		<item>
		<title>WordPress and Translatable Javascript Strings</title>
		<link>http://feedproxy.google.com/~r/LessThanWeb/~3/oxeF24_JL2U/wordpress-and-translatable-javascript-strings</link>
		<comments>http://www.lessthanweb.com/blog/wordpress-and-translatable-javascript-strings#comments</comments>
		<pubDate>Tue, 01 Jan 2013 21:56:47 +0000</pubDate>
		<dc:creator>Anze Stokelj</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.lessthanweb.com/?p=218</guid>
		<description><![CDATA[Ever wondered on how to make Javascript strings translatable in WordPress theme or plugin? Well I did and it looks like it&#8217;s a really easy thing to do. To make Javascript strings translatable you need to use the function wp_localize_script. Here&#8217;s a simple example on how to do it with custom Javascript file. First we need [...]]]></description>
				<content:encoded><![CDATA[<p>Ever wondered on how to make Javascript strings translatable in WordPress theme or plugin? Well I did and it looks like it&#8217;s a really easy thing to do.</p>
<p>To make Javascript strings translatable you need to use the function <code><a href="http://http://codex.wordpress.org/Function_Reference/wp_localize_script" target="_blank">wp_localize_script</a></code>.</p>
<p>Here&#8217;s a simple example on how to do it with custom Javascript file.</p>
<p><span id="more-218"></span></p>
<p>First we need to add our custom Javascript file to theme or plugin using <code><a href="http://http://codex.wordpress.org/Function_Reference/wp_enqueue_script" target="_blank">wp_enqueue_script</a></code>.</p>
<pre class="brush: php; title: ; notranslate">function javascript_files() {
	//    Adding custom javascript file to theme or plugin
	wp_enqueue_script('some_handle_name', get_template_directory_uri().'/js/javascript.js');

	//    Create array with values that are going to be used in Javascript file itself
	$translations = array('some_name' =&gt; __('Some text'), 'another_key' =&gt; '1');

	//    This line is the key:
	//    &quot;some_handle_name&quot; should match the wp_enqueue_script handle
	//    &quot;object&quot; can be named anything, will be used in the Javascript file itself to call the value like: object.some_name
	//    $translations is of course the above array with keys and values
	wp_localize_script('some_handle_name', 'object', $translations);
}
add_action('wp_enqueue_scripts', 'javascript_files');</pre>
<p>Then in Javascript file, we can simply call the translated values like this:</p>
<pre class="brush: jscript; title: ; notranslate">console.log(object.some_name); // Will output &quot;Some text&quot;
console.log(object.another_key); // Will output &quot;1&quot;</pre>
<p>And that&#8217;s it. Really simple thing to do.</p>
<img src="http://feeds.feedburner.com/~r/LessThanWeb/~4/oxeF24_JL2U" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.lessthanweb.com/blog/wordpress-and-translatable-javascript-strings/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.lessthanweb.com/blog/wordpress-and-translatable-javascript-strings</feedburner:origLink></item>
		<item>
		<title>Testimonials Plugin Updated to Version 1.3.2</title>
		<link>http://feedproxy.google.com/~r/LessThanWeb/~3/7jju4240LSg/testimonials-plugin-updated-to-version-1-3-2</link>
		<comments>http://www.lessthanweb.com/blog/testimonials-plugin-updated-to-version-1-3-2#comments</comments>
		<pubDate>Tue, 11 Dec 2012 22:11:51 +0000</pubDate>
		<dc:creator>Anze Stokelj</dc:creator>
				<category><![CDATA[LTW Testimonials]]></category>
		<category><![CDATA[Plugin]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[testimonials]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.lessthanweb.com/?p=213</guid>
		<description><![CDATA[Quick update for the Testimonials plugin. Fixes a few problems with the new WordPress 3.5 version. Log of all the changes: Version 1.3.2 (2012/12/11) * Fixed the location of the dropdown filter that contains the groups as it was shifted to the left * Fixed a few NOTICE bugs in the widget part of the [...]]]></description>
				<content:encoded><![CDATA[<p>Quick update for the <a title="WP Plugin – LTW Testimonials" href="http://www.lessthanweb.com/products/wp-plugin-ltw-testimonials">Testimonials</a> plugin. Fixes a few problems with the new WordPress 3.5 version.</p>
<p>Log of all the changes:</p>
<p><span id="more-213"></span></p>
<pre>Version 1.3.2 (2012/12/11)
 * Fixed the location of the dropdown filter that contains the groups as it was shifted to the left
 * Fixed a few NOTICE bugs in the widget part of the plugin
 * Fixed WARNING bug that basically killed the widget as there was no $wpdb-&gt;prepare parameter set. Removed the $wpdb-&gt;prepare as there is no need for it
 * Fixed NOTICE bug where an empty variable was sent to $wpdb-&gt;prepare for no reason at all, was probably drunk when I added that (not that I drink)</pre>
<img src="http://feeds.feedburner.com/~r/LessThanWeb/~4/7jju4240LSg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.lessthanweb.com/blog/testimonials-plugin-updated-to-version-1-3-2/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.lessthanweb.com/blog/testimonials-plugin-updated-to-version-1-3-2</feedburner:origLink></item>
		<item>
		<title>Add Custom Button to WordPress Visual Editor</title>
		<link>http://feedproxy.google.com/~r/LessThanWeb/~3/7eVe2ZY0sIo/add-custom-button-to-wordpress-visual-editor</link>
		<comments>http://www.lessthanweb.com/blog/add-custom-button-to-wordpress-visual-editor#comments</comments>
		<pubDate>Wed, 05 Dec 2012 13:58:45 +0000</pubDate>
		<dc:creator>Anze Stokelj</dc:creator>
				<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.lessthanweb.com/?p=209</guid>
		<description><![CDATA[Yesterday I wrote an post on responsive web design and each time I wanted to mark the words with the &#60;code&#62; HTML tag, I had to switch to HTML editor, select the word again and click on the code button. Well that was pain in the ass and I don&#8217;t want to do that again. :) [...]]]></description>
				<content:encoded><![CDATA[<p>Yesterday I wrote an post on <a title="Responsive Web Design and CSS3 Media Queries" href="http://www.lessthanweb.com/blog/responsive-web-design-and-css3-media-queries">responsive web design</a> and each time I wanted to mark the words with the &lt;code&gt; HTML tag, I had to switch to HTML editor, select the word again and click on the code button. Well that was pain in the ass and I don&#8217;t want to do that again. :) Now, I knew that you can easily show the hidden buttons to the visual editor.</p>
<p>Here&#8217;s an example on how to add the hidden buttons to the visual editor.</p>
<p><span id="more-209"></span></p>
<pre class="brush: php; title: ; notranslate">
function ltw_mce_buttons_2($buttons)
{
	//    Add the hidden buttons to the $buttons array
	$buttons[] = 'sup';
	$buttons[] = 'sub';

	return $buttons;
}
add_filter('mce_buttons_2', 'ltw_mce_buttons_2');
</pre>
<p>What does <code>mce_buttons_2</code> filter do? Basically it means that the buttons will be added to the second row in the visual editor. You can of course also use: <code>mce_buttons</code> (first row), <code>mce_buttons_2</code> (second row), <code>mce_buttons_3</code> (third row) and <code>mce_buttons_4</code> (fourth row). Easy right?</p>
<p><a href="http://www.tinymce.com/wiki.php/Buttons/controls" target="_blank">Here</a> is the full list of buttons that you can show.</p>
<p>Now, I wanted to add a button to the visual editor that will add &lt;code&gt; HTML tags around the selected word. There are two ways, I could add it as a real button which means I need to write the Javascript plugin for <a href="http://www.tinymce.com/" target="_blank">TinyMCE</a> (is the editor that the WordPress uses in case you didn&#8217;t know that). The second way, the easier and quicker way is to simply add it to the custom styles. So yeah, let&#8217;s do the second version. :)</p>
<h2>Enable Style Dropdown</h2>
<p>First we need to enable the style dropdown in the visual editor. The code to show the style dropdown is basically the same as I have posted it above. But in this case I want the style dropdown at the begining of the second row and for that we need to insert the button as the first item in the array using <a href="http://php.net/manual/en/function.array-unshift.php" target="_blank">array_unshift</a> php function.</p>
<pre class="brush: php; title: ; notranslate">
function ltw_mce_buttons_2($buttons)
{
	array_unshift($buttons, 'styleselect');

	return $buttons;
}
add_filter('mce_buttons_2', 'ltw_mce_buttons_2');
</pre>
<p>If you load the editor now, you will see that the styles dropdown is shown in the second row and it contains some default style formats.</p>
<p>We need to add our own.</p>
<h2>Register Our Own Style Format</h2>
<p>Basically we will register our own style format and set some options for it and we need to make it to act as inline element not block element.</p>
<p>Here&#8217;s the code:</p>
<pre class="brush: php; title: ; notranslate">function ltw_tiny_mce_before_init($init_array)
{
	//	Set the settings.
	//	title = title that will be shown in the dropdown
	//	inline = name of the inline element, this must be valid HTML element
	//	wrapper = means that the element in question is a container, a closing tag will be added after the selected text
	$style_formats = array(
		array(
			'title' =&gt; 'code',
			'inline' =&gt; 'code', // To make code act as a block element, change 'inline' to 'block'
			'wrapper' =&gt; true
		)
	);

	//	TinyMCE uses json for configuration of the buttons so we need to use json_encode
	$init_array['style_formats'] = json_encode($style_formats);

	return $init_array;
}
add_filter('tiny_mce_before_init', 'ltw_tiny_mce_before_init');</pre>
<p>As you can see we added a filter called <code>tiny_mce_before_init</code> and set some options for the custom style format.</p>
<p>There are a few extra options like adding class, styles, etc. that I did not use as I don&#8217;t need them in this case.</p>
<p>Now reload the editor and you have a code style in the dropdown. Easy, the end. ;)</p>
<img src="http://feeds.feedburner.com/~r/LessThanWeb/~4/7eVe2ZY0sIo" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.lessthanweb.com/blog/add-custom-button-to-wordpress-visual-editor/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		<feedburner:origLink>http://www.lessthanweb.com/blog/add-custom-button-to-wordpress-visual-editor</feedburner:origLink></item>
		<item>
		<title>Responsive Web Design and CSS3 Media Queries</title>
		<link>http://feedproxy.google.com/~r/LessThanWeb/~3/PPjwAS79uKE/responsive-web-design-and-css3-media-queries</link>
		<comments>http://www.lessthanweb.com/blog/responsive-web-design-and-css3-media-queries#comments</comments>
		<pubDate>Tue, 04 Dec 2012 20:29:26 +0000</pubDate>
		<dc:creator>Anze Stokelj</dc:creator>
				<category><![CDATA[CSS3]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[XHTML / CSS]]></category>

		<guid isPermaLink="false">http://www.lessthanweb.com/?p=197</guid>
		<description><![CDATA[You have probably already heard of responsive web design (RWD) by now. It is basically a fancy term on how to make your website adjust to different devices like tablets and mobiles. And for that you need CSS media queries. Let&#8217;s get down and dirty right away. On the screenshot below you can see an [...]]]></description>
				<content:encoded><![CDATA[<p>You have probably already heard of responsive web design (RWD) by now. It is basically a fancy term on how to make your website adjust to different devices like tablets and mobiles. And for that you need CSS media queries.</p>
<p>Let&#8217;s get down and dirty right away.</p>
<p><span id="more-197"></span></p>
<p>On the screenshot below you can see an example of a page not using CSS3 media queries and the same page that is using media queries.</p>
<div id="attachment_206" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.lessthanweb.com/blog/responsive-web-design-and-css3-media-queries/css3_media_queries_intro_example" rel="attachment wp-att-206"><img class="size-medium wp-image-206" title="Without and With CSS3 Media Queries" src="http://www.lessthanweb.com/wp-content/uploads/2012/12/css3_media_queries_intro_example-300x225.png" alt="Without and With CSS3 Media Queries" width="300" height="225" /></a><p class="wp-caption-text">Left screenshot shows example page on mobile without using media queries and right side uses them. See the difference?</p></div>
<p>I&#8217;m going to use <a href="http://www.lessthanweb.com/demo/responsive-design-css3-media-queries/index.html" target="_blank">this example page</a> to quickly explain the media queries hence the basic design and layout.</p>
<p>You can also download the full source code of the example page.</p>
<div class="view_demo_box"><div class="demo" style="width: 49%"><a href="http://www.lessthanweb.com/demo/responsive-design-css3-media-queries/index.html" onclick="_gaq.push(['_trackEvent', 'Demo', 'Demo Responsive Web Design and CSS3 Media Queries']);" target="_blank">View Demo</a></div><div class="source" style="width: 49%"><a href="http://www.lessthanweb.com/demo/responsive-design-css3-media-queries/responsive-design-css3-media-queries.zip" onclick="_gaq.push(['_trackEvent', 'Downloads', 'Source Responsive Web Design and CSS3 Media Queries']);">Download Source</a></div></div>
<h2>Viewport Meta Tag</h2>
<p>The first step in making your website to adjust to different devices is to set the meta tag called <code>viewport</code>.</p>
<p>Here is what you should add to the <code>head</code> of the HTML document:</p>
<pre class="brush: xml; title: ; notranslate">&lt;meta name=&quot;viewport&quot; content=&quot;width=device-width&quot;&gt;</pre>
<p>The <code>width</code> property sets the size of the device&#8217;s viewport.</p>
<p>There are a few ways of setting the <code>width</code> property. For example, if you have a website that is designed for mobiles only and the site&#8217;s width is 320 pixels, you can set the <code>width</code> property to <code>width=320</code>. But the best way to do this is to let the device set the width of the viewport by setting the <code>width</code> property to <code>device-width</code>.</p>
<p>What is the viewport? Basically it&#8217;s the screen of the device where all the magic happens. :)</p>
<p>Once you set this meta tag, the next step is to set some CSS media queries.</p>
<h2>Media Queries</h2>
<p>CSS Media queries allow you to target CSS rules based on screen size, device orientation and so on.. You insert them into your .css file and it looks like this:</p>
<pre class="brush: css; title: ; notranslate">
@media screen and (max-width: 980px) {
    /* CSS rules inside this block will be used when the size of the viewport is 980 pixels or less */
}
@media screen and (max-width: 830px) {
    /* CSS rules inside this block will be used when the size of the viewport is 830 pixels or less */
}
</pre>
<p>How to know where to set breakpoints? Well, the most simple way is to load the page in your browser and resize it. When you see that the elements of the page are not as you want them, set media queries.</p>
<p>Looking at the <a href="http://www.lessthanweb.com/demo/responsive-design-css3-media-queries/index.html" target="_blank">example page</a> you can see that I have set 3 media queries.</p>
<p>The example page has a fixed layout, width set to 980 pixels. That means that the elements need to be fluid when the width of the viewport is 980 pixels or less.</p>
<pre class="brush: css; title: ; notranslate">/*
	For 980px or less
*/
@media screen and (max-width: 980px) {
	#wrapper {
		width: auto;
		padding: 0 2px;
	}
	#content_container #content {
		width: 72%;
	}
	#content_container #sidebar {
		width: 25%;
	}
}</pre>
<p>That&#8217;s it, if you now resize the browser below 980 pixels, you will see that the elements of the page become fluid.</p>
<p>The next breakpoint is set at 830 pixels of width. Why? Because I want to move the header menu below the title and also make the images fluid instead of fixed size.</p>
<pre class="brush: css; title: ; notranslate">/*
	For 830px or less
*/
@media screen and (max-width: 830px) {
	#header {
		height: 100%;
	}
	#header #logo,
	#header #menu {
		float: none;
	}
	#header #logo {
		margin-top: 15px;
	}
	#header #menu {
		margin: 15px 0 0 10px;
	}
	#header #menu ul li {
		margin-bottom: 10px;
	}
	#content_container #content img {
		width: 25%;
	}
	#content_container #content img.full_width {
		width: 100%;
	}
}</pre>
<p>Since I want to move the menu under title, I need to set the <code>float</code> property to <code>none</code> for the header elements (title and menu).</p>
<p>In this stage, I also set the <code>width</code> property to % instead of pixels so that the images become fluid and resize nicely.</p>
<p>Next and last breakpoint is set at 600 pixels of width.</p>
<pre class="brush: css; title: ; notranslate">/*
	For 600px or less
*/
@media screen and (max-width: 600px) {
	#content_container #content {
		width: 100%;
	}
	#content_container #sidebar {
		display: none;
	}
}</pre>
<p>In this media query I resize the content area to full width (100%) and hide the sidebar. You could of course move the sidebar below the content but I choose to hide it in this example.</p>
<p>Here are the results in portrait and landscape orientation on mobile.</p>
<div id="attachment_208" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.lessthanweb.com/wp-content/uploads/2012/12/phone_portrait.png"><img class="size-full wp-image-208" title="Phone Portrait Media Queries Example" src="http://www.lessthanweb.com/wp-content/uploads/2012/12/phone_portrait.png" alt="Phone Portrait Media Queries Example" width="300" height="520" /></a><p class="wp-caption-text">Showing the example page in mobile in portrait orientation</p></div>
<div id="attachment_207" class="wp-caption aligncenter" style="width: 530px"><a href="http://www.lessthanweb.com/wp-content/uploads/2012/12/phone_landscape.png"><img class="size-full wp-image-207" title="Phone Landscape Media Queries Example" src="http://www.lessthanweb.com/wp-content/uploads/2012/12/phone_landscape.png" alt="Phone Landscape Media Queries Example" width="520" height="300" /></a><p class="wp-caption-text">Showing the example page in mobile in landscape orientation</p></div>
<p>And that&#8217;s it really. Have fun. ;)</p>
<img src="http://feeds.feedburner.com/~r/LessThanWeb/~4/PPjwAS79uKE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.lessthanweb.com/blog/responsive-web-design-and-css3-media-queries/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.lessthanweb.com/blog/responsive-web-design-and-css3-media-queries</feedburner:origLink></item>
		<item>
		<title>Extended Recent Posts – WordPress Plugin</title>
		<link>http://feedproxy.google.com/~r/LessThanWeb/~3/83VpqjpptAI/extended-recent-posts-wordpress-plugin</link>
		<comments>http://www.lessthanweb.com/blog/extended-recent-posts-wordpress-plugin#comments</comments>
		<pubDate>Thu, 22 Nov 2012 23:18:11 +0000</pubDate>
		<dc:creator>Anze Stokelj</dc:creator>
				<category><![CDATA[Plugin]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.lessthanweb.com/?p=184</guid>
		<description><![CDATA[A few days ago I have updated this websites design and I wanted to put the recent posts into the footers sidebar on the left side. Now yes, with WordPress you get a Recent Posts widget but that widget only shows the titles of the recent posts. Hmm, yeah, not really what I need. So [...]]]></description>
				<content:encoded><![CDATA[<p>A few days ago I have updated this websites design and I wanted to put the recent posts into the footers sidebar on the left side. Now yes, with WordPress you get a Recent Posts widget but that widget only shows the titles of the recent posts. Hmm, yeah, not really what I need.</p>
<p><span id="more-184"></span></p>
<p>So I went searching for a really simple wordpress widget that will show just the title, excerpt and maybe a date also. That&#8217;s all I wanted! But I could not find it. All other widgets had loads of extra features that I won&#8217;t really ever need so what&#8217;s the point?!?!</p>
<p>And voila, a few minutes and here I have a really simple widget that works and does exactly what I want.</p>
<p>And I am calling it <a title="Extended Recent Posts" href="http://www.lessthanweb.com/wordpress-plugins/extended-recent-posts">Extended Recent Posts</a>.</p>
<p>Check it out in the footer, left side or click the link above for plugin page. ;)</p>
<img src="http://feeds.feedburner.com/~r/LessThanWeb/~4/83VpqjpptAI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.lessthanweb.com/blog/extended-recent-posts-wordpress-plugin/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.lessthanweb.com/blog/extended-recent-posts-wordpress-plugin</feedburner:origLink></item>
		<item>
		<title>Simple CSS Tabs with jQuery – Version 2</title>
		<link>http://feedproxy.google.com/~r/LessThanWeb/~3/oVaSMH_xoG8/simple-css-tabs-with-jquery-version-2</link>
		<comments>http://www.lessthanweb.com/blog/simple-css-tabs-with-jquery-version-2#comments</comments>
		<pubDate>Thu, 22 Nov 2012 13:01:27 +0000</pubDate>
		<dc:creator>Anze Stokelj</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[XHTML / CSS]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[tabs]]></category>
		<category><![CDATA[xhtml]]></category>

		<guid isPermaLink="false">http://www.lessthanweb.com/?p=176</guid>
		<description><![CDATA[This is the updated version of the CSS tabs that I have posted long time ago. I have included some of the features that were requested. What&#8217;s new in this version of CSS tabs? Quite a few things. You can now set multiple tab containers per page, set active tabs by using hash in the [...]]]></description>
				<content:encoded><![CDATA[<p>This is the updated version of the <a title="Simple CSS Tabs with jQuery" href="http://www.lessthanweb.com/blog/simple-css-tabs-with-jquery">CSS tabs</a> that I have posted long time ago. I have included some of the features that were requested.</p>
<p>What&#8217;s new in this version of CSS tabs? Quite a few things. You can now set multiple tab containers per page, set active tabs by using hash in the link and two new designs.</p>
<p>The demo and source code are available. If you want to go into details on how everything works, keep reading.</p>
<p><span id="more-176"></span></p>
<div class="view_demo_box"><div class="demo" style="width: 49%"><a href="http://www.lessthanweb.com/demo/simple-css-tabs-with-jquery-v2/index.html" onclick="_gaq.push(['_trackEvent', 'Demo', 'Demo Simple CSS Tabs with jQuery V2']);" target="_blank">View Demo</a></div><div class="source" style="width: 49%"><a href="http://www.lessthanweb.com/demo/simple-css-tabs-with-jquery-v2/simple-css-tabs-with-jquery-v2.zip" onclick="_gaq.push(['_trackEvent', 'Downloads', 'Source Simple CSS Tabs with jQuery V2']);">Download Source</a></div></div>
<h2>HTML</h2>
<p>Let&#8217;s take a look at a few things that are new in the HTML. I will take only the HTML code of the first tabs as an example.</p>
<p>Having 3 separate tab containers means that an extra div tag needs to be added around the tab and content containers. This container is called <strong>tabs_wrapper</strong>. Not a must but it helps. ;)</p>
<p>The big new thing that we have here is the <code>rel</code> attribute in the link tag. This <code>rel</code> attribute must match the <code>href</code> attribute and also the <code>id</code> attribute of the content container.</p>
<p>Let&#8217;s look at Tab 1 for example. The <code>href</code> and <code>rel</code> attributes in the link have the same word in this case &#8220;tab1&#8243;. This word needs to be set as an <code>id</code> attribute for the content container div.</p>
<p>Here are the two lines that must match.</p>
<pre class="brush: xml; title: ; notranslate">
&lt;!--    Link href and rel attributes must be the same --&gt;
&lt;li&gt;&lt;a href=&quot;#tab1&quot; rel=&quot;tab1&quot;&gt;Tab 1&lt;/a&gt;&lt;/li&gt;
&lt;!--   The id attribute must match the link href and rel attributes --&gt;
&lt;div id=&quot;tab1&quot; style=&quot;display: block;&quot;&gt;
</pre>
<p>Now you can look at the whole block of code below and as you can see, each tab link has <code>href</code> and <code>rel</code> attributes that match each other and also the <code>id</code> attribute of the content container.</p>
<pre class="brush: xml; title: ; notranslate">
&lt;div class=&quot;tabs_wrapper&quot;&gt;
	&lt;!-- Original tabs START --&gt;
	&lt;div id=&quot;original_tabs&quot;&gt;
		&lt;ul&gt;
			&lt;li class=&quot;active&quot;&gt;&lt;a href=&quot;#tab1&quot; rel=&quot;tab1&quot;&gt;Tab 1&lt;/a&gt;&lt;/li&gt;
			&lt;li&gt;&lt;a class=&quot;icon_accept&quot; href=&quot;#tab2&quot; rel=&quot;tab2&quot;&gt;Tab with icon&lt;/a&gt;&lt;/li&gt;
			&lt;li&gt;&lt;a href=&quot;#tab3&quot; rel=&quot;tab3&quot;&gt;Long name for the last tab&lt;/a&gt;&lt;/li&gt;
		&lt;/ul&gt;
	&lt;/div&gt;
	&lt;div id=&quot;original_tabs_content&quot;&gt;
		&lt;div id=&quot;tab1&quot; class=&quot;tab_content&quot; style=&quot;display: block;&quot;&gt;
			&lt;p&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum nibh urna, euismod ut ornare non, volutpat vel tortor. Integer laoreet placerat suscipit. Sed sodales scelerisque commodo. Nam porta cursus lectus. Proin nunc erat, gravida a facilisis quis, ornare id lectus. Proin consectetur nibh quis urna gravida mollis.&lt;/p&gt;
		&lt;/div&gt;
		&lt;div id=&quot;tab2&quot; class=&quot;tab_content&quot;&gt;
			&lt;p&gt;This tab has icon in it.&lt;/p&gt;
		&lt;/div&gt;
		&lt;div id=&quot;tab3&quot; class=&quot;tab_content&quot;&gt;
			&lt;p&gt;Suspendisse blandit velit eget erat suscipit in malesuada odio venenatis.&lt;/p&gt;
		&lt;/div&gt;
	&lt;/div&gt;
	&lt;!-- Original tabs END --&gt;
&lt;/div&gt;
</pre>
<p>That&#8217;s really the only change when it comes to HTML. It&#8217;s still pretty simple.</p>
<h2>CSS</h2>
<p>The next part is the CSS styles. They are the same as they were before really. Nothing changed apart from the naming as we now have 3 different styles of tabs. We can skip this part.</p>
<h2>jQuery</h2>
<p>Ah yes, the jQuery time. :) When it comes to jQuery, I have added a few things.</p>
<p>Before I post the code, let me explain that now you can use hash in the URL and the tab will be active. You can even select multiple tabs in different tab container using hash by separating the IDs with a comma. Look at the example and click on the link above the tabs.</p>
<p>Here is the code, I have commented it as much as possible. If something is unclear, do ask.</p>
<pre class="brush: jscript; title: ; notranslate">
$(document).ready(function(){
	//	Main function that shows and hides the requested tabs and their content
	var set_tab = function(tab_container_id, tab_id){
		//	Remove class &quot;active&quot; from currently active tab
		$('#' + tab_container_id + ' ul li').removeClass('active');

		//	Now add class &quot;active&quot; to the selected/clicked tab
		$('#' + tab_container_id + ' a[rel=&quot;'+tab_id+'&quot;]').parent().addClass(&quot;active&quot;);

		//	Hide contents for all the tabs.
		//	The '_content' part is merged with tab_container_id and the result
		//	is the content container ID.
		//	For example for the original tabs: tab_container_id + '_content' = original_tabs_content
		$('#' + tab_container_id + '_content .tab_content').hide();

		//	Show the selected tab content
		$('#' + tab_container_id + '_content #' + tab_id).fadeIn();
	}

	//	Function that gets the hash from URL
	var get_hash = function(){
		if (window.location.hash) {
			//	Get the hash from URL
			var url = window.location.hash;

			//	Remove the #
			var current_hash = url.substring(1);

			//	Split the IDs with comma
			var current_hashes = current_hash.split(&quot;,&quot;);

			//	Loop over the array and activate the tabs if more then one in URL hash
			$.each(current_hashes, function(i, v){
				set_tab($('a[rel=&quot;'+v+'&quot;]').parent().parent().parent().attr('id'), v);
			});
		}
	}

	//	Called when page is first loaded or refreshed
	get_hash();

	//	Looks for changes in the URL hash
	$(window).bind('hashchange', function() {
		get_hash();
	});

	//	Called when we click on the tab itself
	$('.tabs_wrapper ul li').click(function() {
		var tab_id = $(this).children('a').attr('rel');

		//	Update the hash in the url
		window.location.hash = tab_id;

		//	Do nothing when tab is clicked
		return false;
	});
});
</pre>
<p>Note: Because of the lack of support for <code>window.location.hash</code> the tabs do not work in IE7 and below!</p>
<p>You can of course recode that part or throw out the whole hash part of the javascript if you do not need it and the tabs should also work in IE7.</p>
<img src="http://feeds.feedburner.com/~r/LessThanWeb/~4/oVaSMH_xoG8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.lessthanweb.com/blog/simple-css-tabs-with-jquery-version-2/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://www.lessthanweb.com/blog/simple-css-tabs-with-jquery-version-2</feedburner:origLink></item>
		<item>
		<title>LTW Testimonial – Update 1.3.1</title>
		<link>http://feedproxy.google.com/~r/LessThanWeb/~3/Id6xqWKFc3E/ltw-testimonial-update-1-3-1</link>
		<comments>http://www.lessthanweb.com/blog/ltw-testimonial-update-1-3-1#comments</comments>
		<pubDate>Thu, 24 May 2012 11:26:02 +0000</pubDate>
		<dc:creator>Anze Stokelj</dc:creator>
				<category><![CDATA[LTW Testimonials]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://www.lessthanweb.com/?p=152</guid>
		<description><![CDATA[A new update for the LTW Testimonials plugin is now available, version 1.3.1. This is a minor update that fixes some of the problems on the latest version of WP. It should now work without any problems. Also, donations are welcome (button located on the plugin page, link to it is below), even small ones [...]]]></description>
				<content:encoded><![CDATA[<p>A new update for the LTW Testimonials plugin is now available, version 1.3.1.</p>
<p>This is a minor update that fixes some of the problems on the latest version of WP.</p>
<p>It should now work without any problems.</p>
<p>Also, donations are welcome (button located on the plugin page, link to it is below), even small ones as it takes a lot of time to keep this plugin alive.</p>
<p><span id="more-152"></span></p>
<p><strong>Version 1.3.1 (2012/05/24)</strong></p>
<ul>
<li>Fixed minor NOTICE bugs</li>
<li>15 testimonials now shown on testimonials list page</li>
<li>Added the missing &#8220;count&#8221; field to the groups table</li>
<li>Fixed the &#8220;show in widget&#8221; checkbox not working</li>
</ul>
<p>To update to the latest version, go to your WP admin plugins page or <a href="http://www.lessthanweb.com/products/wp-plugin-ltw-testimonials">click here</a> for the download link.</p>
<img src="http://feeds.feedburner.com/~r/LessThanWeb/~4/Id6xqWKFc3E" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.lessthanweb.com/blog/ltw-testimonial-update-1-3-1/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.lessthanweb.com/blog/ltw-testimonial-update-1-3-1</feedburner:origLink></item>
	</channel>
</rss>
