<?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>Weblog Tools Collection &#187; functions</title>
	<atom:link href="http://weblogtoolscollection.com/archives/tag/functions/feed/" rel="self" type="application/rss+xml" />
	<link>http://weblogtoolscollection.com</link>
	<description>Weblog Tools Blogging Tools Blog</description>
	<lastBuildDate>Mon, 13 Feb 2012 13:00:19 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>How Do You Do That?</title>
		<link>http://weblogtoolscollection.com/archives/2009/11/18/how-do-you-do-that/</link>
		<comments>http://weblogtoolscollection.com/archives/2009/11/18/how-do-you-do-that/#comments</comments>
		<pubDate>Wed, 18 Nov 2009 12:55:08 +0000</pubDate>
		<dc:creator>James Dimick</dc:creator>
				<category><![CDATA[HOW-TO]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WordPress Discussions]]></category>
		<category><![CDATA[Wordpress for Beginners]]></category>
		<category><![CDATA[WordPress Tips]]></category>
		<category><![CDATA[admin]]></category>
		<category><![CDATA[beginner]]></category>
		<category><![CDATA[functions]]></category>
		<category><![CDATA[links]]></category>
		<category><![CDATA[plugins]]></category>
		<category><![CDATA[questions]]></category>
		<category><![CDATA[themes]]></category>
		<category><![CDATA[urls]]></category>

		<guid isPermaLink="false">http://weblogtoolscollection.com/?p=7131</guid>
		<description><![CDATA[Ever wanted to do something in WordPress but just wasn&#8217;t sure how? In my experience this happens quite often, mostly with people new to WordPress. But, even the experts run into trouble sometimes. Today I thought I&#8217;d start a series of posts which will aim to explain how to do certain things in WordPress. Hopefully this will cover anything from quick tips and simple little functions, all the way up to more complex custom code and the like. So, stick around and you just might learn something. I think I&#8217;ll kick off the series with a couple simple ones&#8230; Why isn&#8217;t this plugin working with my theme? This is probably one of the most common issues I read about regarding WordPress. Sometimes even more experienced WPers can get this one wrong. Now, I&#8217;m not saying this is the solution to all problems between plugins and themes. Its just that this [...]]]></description>
			<content:encoded><![CDATA[<p>Ever wanted to do something in WordPress but just wasn&#8217;t sure how? In my experience this happens quite often, mostly with people new to WordPress. But, even the experts run into trouble sometimes. Today I thought I&#8217;d start a series of posts which will aim to explain how to do certain things in WordPress. Hopefully this will cover anything from quick tips and simple little functions, all the way up to more complex custom code and the like. So, stick around and you just might learn something. <img src='http://weblogtoolscollection.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>I think I&#8217;ll kick off the series with a couple simple ones&#8230;</p>
<ul>
<li>
<h5>Why isn&#8217;t this plugin working with my theme?</h5>
<p>This is probably one of the most common issues I read about regarding WordPress. Sometimes even more experienced WP<em>ers</em> can get this one wrong. Now, I&#8217;m not saying this is the solution to <strong>all</strong> problems between plugins and themes. Its just that this little bugger is often the culprit.</p>
<p>Try ensuring that your theme has <code>&lt;?php <a href="http://codex.wordpress.org/Theme_Development#Plugin_API_Hooks">wp_head</a>() ?&gt;</code> somewhere inside the <code>&lt;head&gt;</code> section of the document. Also, for that matter, make sure it has <code>&lt;?php <a href="http://codex.wordpress.org/Theme_Development#Plugin_API_Hooks">wp_footer</a>() ?&gt;</code> somewhere in the foot of the document; Before the <code>&lt;/body&gt;</code> tag.</p>
<p>If your theme lacks these function calls many plugins that manipulate your theme will not be able to hook into the required areas. This can cause many headaches.</p>
<p>If you have no idea what I&#8217;m talking about, you may be better off having a coder buddy take a look at the theme for you. Or you can also contact the theme author, if the theme you use was created by someone else.</li>
<li>
<h5>How come my URLs are yucky?</h5>
<p>Or, &#8220;<em>How come my URLs look like <code>www.mysite.com?p=123</code> instead of <code>www&#8203;.mysite.&#8203;com&#8203;/my-&#8203;sample-&#8203;post/</code>?</em>&#8221;</p>
<p>This one is right up there with the previous question. I see it all the time. However, more and more web hosts these days support the &#8220;<em>nice</em>&#8221; URLs by default without requiring any extra effort. So, its just a matter of going into the WordPress control panel, changing your Permalink Settings and then saving. Unfortunately, we&#8217;re not all this lucky&#8230;</p>
<p>The first thing to try would be to contact your web host support and make sure they have whats known as <code>mod_rewrite</code> <em>(or similar functionality)</em> enabled on your account. If such functionality is not available on your web host, and you really need this feature, you may need to upgrade to a new host that does support it.</p>
<p>If your host does support it and has it enabled on your account, but it still doesn&#8217;t work, you can check that WordPress is able to write to the <code>.htaccess</code> file <em>(which is where all the &#8220;nice&#8221; URL magic happens)</em>.</p>
<p>For WordPress, on Unix-based systems, the htaccess file should be &#8220;<em><code><a href="http://codex.wordpress.org/Changing_File_Permissions#About_Chmod">CHMOD</a></code>ed</em>&#8221; to at least <code>666</code>. On Windows-based systems the procedure is a bit different. It can be different depending on your particular setup so I won&#8217;t go into that.</p>
<p>Basically, as was the case with the previous question, you may need to seek help to figure this out. If you don&#8217;t have a code buddy, get one! They are really great to have around. Just make sure you buy them a nice gift for their trouble. <img src='http://weblogtoolscollection.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </li>
<li>
<h5>Can I have a link to login to WordPress somewhere in my theme?</h5>
<p>Sure! It&#8217;s actually easier than you might think&#8230;</p>
<p>Some themes have a link for that already. But, there are also some that seem to lack this obvious and simple feature. You can easily add this to any theme yourself. No need for any programming knowledge. Simply add <code>&lt;?php <a href="http://codex.wordpress.org/Function_Reference/wp_loginout">wp_loginout</a>() ?&gt;</code> somewhere in your theme and you&#8217;re done. Easy right?</p>
<p>Another nice function along the same lines is <code>&lt;?php <a href="http://codex.wordpress.org/Function_Reference/wp_register">wp_register</a>() ?&gt;</code>, which will show a link to your registration page <em>(if your settings allow users to register)</em>, or a link to the WordPress control panel if you are already logged in.</p>
<p>Do note though that by default the link will be output wrapped inside <code>&lt;li&gt;</code> tags. This is so you can include the link in a list of other links, like a &#8220;<em>meta</em>&#8221; section. If, however, that is not how you want it to be output you can use the function like <code>&lt;?php wp_register('', '') ?&gt;</code>. That will simply output the link and nothing else.</p>
<p>An example of how to customize that is something like <code>&lt;?php wp_register('&lt;p&gt;', '&lt;/p&gt;') ?&gt;</code>, which will output the link wrapped in its own paragraph. Just change the opening and closing tags in the function to make it output how you want. Dead simple!</li>
</ul>
<p>That&#8217;s all for now&#8230; I hope it helps!</p>
<p style="background-color:#fae8d3;padding:5px 10px;margin-bottom:20px">Do you have a question about WordPress? Want to see it answered here on Weblog Tools Collection? If so, please <a href="http://weblogtoolscollection.com/archives/2007/02/06/contact-me/">send us an E-Mail</a> or drop a comment here. Your question just might be featured in the series!</p>
]]></content:encoded>
			<wfw:commentRss>http://weblogtoolscollection.com/archives/2009/11/18/how-do-you-do-that/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>How to Highlight Search Terms with jQuery</title>
		<link>http://weblogtoolscollection.com/archives/2009/04/10/how-to-highlight-search-terms-with-jquery/</link>
		<comments>http://weblogtoolscollection.com/archives/2009/04/10/how-to-highlight-search-terms-with-jquery/#comments</comments>
		<pubDate>Fri, 10 Apr 2009 08:00:29 +0000</pubDate>
		<dc:creator>Thaya Kareeson</dc:creator>
				<category><![CDATA[HOW-TO]]></category>
		<category><![CDATA[WordPress FAQs]]></category>
		<category><![CDATA[functions]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[search]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WordPress Hack]]></category>

		<guid isPermaLink="false">http://weblogtoolscollection.com/?p=5564</guid>
		<description><![CDATA[A neat way to spice up your WordPress search page is to highlight search terms within your search results. I&#8217;ve seen some tutorials on the net on how to do this, but I haven&#8217;t found one that highlights both title and post content and is a drop-in modification for WordPress. Today I will bring you this drop-in hack for highlighting search terms on your WordPress blog. Installation 1. Copy and paste the following code into your theme&#8217;s functions.php file: function hls_set_query() { $query = attribute_escape(get_search_query()); if(strlen($query) > 0){ echo ' &#60;script type="text/javascript"&#62; var hls_query = "'.$query.'"; &#60;/script&#62; '; } } function hls_init_jquery() { wp_enqueue_script('jquery'); } add_action('init', 'hls_init_jquery'); add_action('wp_print_scripts', 'hls_set_query'); If you are having issues with copy-paste from this blog, here is a link to the same code in a txt file: Code to insert into functions.php 2. Copy and paste the following code into your theme&#8217;s header.php file (just before [...]]]></description>
			<content:encoded><![CDATA[<p>A neat way to spice up your WordPress search page is to highlight search terms within your search results.  I&#8217;ve seen some tutorials on the net on how to do this, but I haven&#8217;t found one that highlights both title and post content and is a drop-in modification for WordPress.  Today I will bring you this drop-in hack for highlighting search terms on your WordPress blog.</p>
<h3>Installation</h3>
<p>1. Copy and paste the following code into your theme&#8217;s functions.php file:</p>
<blockquote>
<pre>
function hls_set_query() {
  $query  = attribute_escape(get_search_query());

  if(strlen($query) > 0){
    echo '
      &lt;script type="text/javascript"&gt;
        var hls_query  = "'.$query.'";
      &lt;/script&gt;
    ';
  }
}

function hls_init_jquery() {
  wp_enqueue_script('jquery');
}

add_action('init', 'hls_init_jquery');
add_action('wp_print_scripts', 'hls_set_query');
</pre>
</blockquote>
<p>If you are having issues with copy-paste from this blog, here is a link to the same code in a txt file: <a href='http://weblogtoolscollection.com/b2-img/2009/04/hls_functions.txt'>Code to insert into functions.php</a></p>
<p>2. Copy and paste the following code into your theme&#8217;s header.php file (just before the &lt;/head&gt; tag is fine):</p>
<blockquote>
<pre>
  &lt;style type="text/css" media="screen"&gt;
    .hls { background: #D3E18A; }
  &lt;/style&gt;
  &lt;script type="text/javascript"&gt;
  jQuery.fn.extend({
    highlight: function(search, insensitive, hls_class){
      var regex = new RegExp("(<[^>]*>)|(\\b"+ search.replace(/([-.*+?^${}()|[\]\/\\])/g,"\\$1") +")", insensitive ? "ig" : "g");
      return this.html(this.html().replace(regex, function(a, b, c){
        return (a.charAt(0) == "&lt;") ? a : "&lt;strong class=\""+ hls_class +"\"&gt;" + c + "&lt;/strong&gt;";
      }));
    }
  });
  jQuery(document).ready(function($){
    if(typeof(hls_query) != 'undefined'){
      $("#post-area").highlight(hls_query, 1, "hls");
    }
  });
  &lt;/script&gt;
</pre>
</blockquote>
<p>(jQuery code slightly adapted from devthought&#8217;s <a href="http://devthought.com/blog/client-side/2009/04/javascript-regexp-based-highlighting-function-for-mootools-and-jquery/">JavaScript RegExp based highlighting</a>.)</p>
<p>If you are having issues with copy-paste from this blog, here is a link to the same code in a txt file: <a href='http://weblogtoolscollection.com/b2-img/2009/04/hls_header.txt'>Code to insert into header.php</a></p>
<p>3. <strong>Very Important:</strong> Next make sure you change &#8220;post-area&#8221; in the code (in step 2) to the HTML tag ID of the area you want your search terms highlighted.  For example, if you do a view source on Weblog Tools Collection&#8217;s search result page, you will see that the results area is enclosed by the tag &#8216;&lt;div id=&#8221;post-area&#8221;&gt;&#8217;.</p>
<p>4. <em>Optional:</em> You can also change the way the highlighted text look by changing the CSS properties of the &#8220;.hls&#8221; class in the code in step 2.</p>
<h3>End Result</h3>
<p>I&#8217;ve searched for &#8220;greet&#8221; on my blog and this is what shows up on the result page:<br />
<a href="http://weblogtoolscollection.com/b2-img/2009/04/search_result.png" rel="thumbnail"><img src="http://weblogtoolscollection.com/b2-img/2009/04/search_result.png" alt="Highlighted Search Results" title="Highlighted Search Results" width="363" height="206" class="alignnone size-full wp-image-5578" /></a></p>
<h3>Conclusion</h3>
<p>Few reasons why I like this method:</p>
<ol>
<li>jQuery will let you highlight any text within any HTML element you desire.  It doesn&#8217;t matter if the text is in the title or is in the actual post content.  Just change the ID tag as needed.</li>
<li>There is no need for a plugin to do some simple search term highlighting.  This method should take you less than 15 minutes to hack into your theme and it makes your WordPress search page look MUCH better.</li>
<li>It is highly customizable (provided that you read some jQuery documentation) to fit any blog&#8217;s needs.</li>
</ol>
<p>Do you have a better way of doing this?  If so, please share in comments!</p>
]]></content:encoded>
			<wfw:commentRss>http://weblogtoolscollection.com/archives/2009/04/10/how-to-highlight-search-terms-with-jquery/feed/</wfw:commentRss>
		<slash:comments>68</slash:comments>
		</item>
		<item>
		<title>If, Then, Else</title>
		<link>http://weblogtoolscollection.com/archives/2008/08/09/if-then-else/</link>
		<comments>http://weblogtoolscollection.com/archives/2008/08/09/if-then-else/#comments</comments>
		<pubDate>Sat, 09 Aug 2008 19:27:09 +0000</pubDate>
		<dc:creator>Jeff Chandler</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[else]]></category>
		<category><![CDATA[functions]]></category>
		<category><![CDATA[if]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[then]]></category>

		<guid isPermaLink="false">http://weblogtoolscollection.com/?p=3894</guid>
		<description><![CDATA[Ever become brave enough to look inside of a WordPress php file? Specifically, a php file from a theme? If you have, you may have noticed that they are filled with If, Then, and Else statements. If you have no idea what these mean, this post is for you. Php has always been a pain for me to understand, but if you think about it in a logical manner, it begins to make sense. If, then and else statements are used as a means of making decisions, similar to the way you and I make decisions in the real world. Here is an example of how this logic works in WordPress. &#60; ?php if (have_posts()) : ?&#62; The if statement within that php function is asking if there are posts. If the blog has posts, WordPress begins processing what is known as &#8220;The Loop&#8220;. &#60;? php while (have_posts()) : the_post(); [...]]]></description>
			<content:encoded><![CDATA[<p>Ever become brave enough to look inside of a WordPress php file? Specifically, a php file from a theme? If you have, you may have noticed that they are filled with If, Then, and Else statements. If you have no idea what these mean, this post is for you.</p>
<p>Php has always been a pain for me to understand, but if you think about it in a logical manner, it begins to make sense. If, then and else statements are used as a means of making decisions, similar to the way you and I make decisions in the real world. Here is an example of how this logic works in WordPress.</p>
<p><strong>&lt; ?php if (have_posts()) : ?&gt;</strong></p>
<p>The if statement within that php function is asking if there are posts. If the blog has posts, WordPress begins processing what is known as &#8220;<a title="http://codex.wordpress.org/the_loop" href="http://codex.wordpress.org/the_loop" target="_blank">The Loop</a>&#8220;.</p>
<p><strong>&lt;? php while (have_posts()) : the_post(); ?&gt;</strong></p>
<p>This piece of code tells WordPress to grab the posts from the MySQL database and display them on your blog. The loop then closes with this function.</p>
<p><strong>&lt;?php endwhile; ?&gt;</strong></p>
<p>If the answer to the <strong>if</strong> question turns out to be no, WordPress bypasses the loop and displays a message that no posts exist. This is where the <strong>else</strong> statement comes into play.</p>
<p><strong><br />
&lt; h2 class=&#8221;center&#8221;&gt;Not Found&lt; /h2&gt;<br />
&lt; p class=&#8221;center&#8221;&gt;Sorry, but you are looking for something that isn&#8217;t here.&lt; /p&gt;<br />
&lt; ?php include (TEMPLATEPATH . &#8220;/searchform.php&#8221;); ?&gt;<br />
&lt; ?php endif; ?&gt;</strong></p>
<p>That last line of code is the if statement and concludes the function.</p>
<p><strong>If</strong>, <strong>then</strong>, and <strong>else</strong> are easy to remember when you think of how you <strong>function</strong> on a daily basis. A real world example, (<strong>If</strong> I am hungry, <strong>Then</strong> I&#8217;ll eat some food, or <strong>Else</strong> I&#8217;ll starve). Maybe not the best example in the world, but you should be able to get the picture.</p>
<p>I&#8217;m no coder by any means but when I read explanations about statements and functions inside of WordPress via Lisa Sabin Wilson&#8217;s <a title="WordPress For Dummies At Amazon" href="http://www.amazon.com/WordPress-Dummies-Computer-Tech/dp/0470149469/ref=pd_bbs_sr_1?ie=UTF8&amp;s=books&amp;qid=1218309580&amp;sr=1-1" target="_blank">WordPress For Dummies</a>, it&#8217;s as if light bulbs turn on inside of my head. One of those &#8220;Ohhhh, so thats what that does&#8221; sort of moments.</p>
<p>Be sure to let me know if this post was of any help to you.</p>
]]></content:encoded>
			<wfw:commentRss>http://weblogtoolscollection.com/archives/2008/08/09/if-then-else/feed/</wfw:commentRss>
		<slash:comments>33</slash:comments>
		</item>
	</channel>
</rss>
<!-- This Quick Cache file was built for (  weblogtoolscollection.com/archives/tag/functions/feed/ ) in 0.60454 seconds, on Feb 14th, 2012 at 8:27 am UTC. -->
<!-- This Quick Cache file will automatically expire ( and be re-built automatically ) on Feb 14th, 2012 at 9:27 am UTC -->
