<?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>bavotasan.com &#187; Meta</title>
	<atom:link href="http://bavotasan.com/tag/meta/feed/" rel="self" type="application/rss+xml" />
	<link>http://bavotasan.com</link>
	<description>by c.bavota</description>
	<lastBuildDate>Tue, 07 Feb 2012 15:42:10 +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>Meta Descriptions for WordPress</title>
		<link>http://bavotasan.com/2010/meta-descriptions-wordpress/</link>
		<comments>http://bavotasan.com/2010/meta-descriptions-wordpress/#comments</comments>
		<pubDate>Sat, 30 Oct 2010 05:30:44 +0000</pubDate>
		<dc:creator>c.bavota</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[header]]></category>
		<category><![CDATA[Meta]]></category>
		<category><![CDATA[meta description]]></category>
		<category><![CDATA[meta tags]]></category>
		<category><![CDATA[posts]]></category>
		<category><![CDATA[search engine]]></category>
		<category><![CDATA[seo]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://bavotasan.com/?p=2931</guid>
		<description><![CDATA[A very important thing to pay attention to when optimizing your site for search engine ranking is creating unique pages meta descriptions for all of the pages on your website that you want to have indexed. If you take a look on Google, or any search engine, you will see a blurb about your page [...]]]></description>
			<content:encoded><![CDATA[<p>A very important thing to pay attention to when optimizing your site for search engine ranking is creating unique pages meta descriptions for all of the pages on your website that you want to have indexed. If you take a look on Google, or any search engine, you will see a blurb about your page beneath the page title. This little bit of text is taken for the text your page has in the meta description tag. No text, no blurb on Google, and possibly no indexing whatsoever.</p>
<div id="attachment_2932" class="wp-caption aligncenter" style="width: 574px"><img src="http://bavotasan.com/wp-content/uploads/2010/10/googledesc.png" alt="Google Example" title="googledesc" width="564" height="90" class="size-full wp-image-2932" /><p class="wp-caption-text">Page description in Google</p></div>
<p>Having a unique title for each page is important, but what is more important is making sure that the description for your page is just as unique and relevant. The great thing about WordPress is that you can use some basic functions to put together a little script that would create a meta description dynamically for each of your pages.</p>
<p>I encountered a few issues trying to put this script together due to the fact that some plugins actually hook into <code>the_content()</code> or <code>the_excerpt()</code> and this causes a lot of issues. The final solution I came up with is below.  Just add the following to your <code>functions.php</code> file within the PHP tags:</p>

<div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> dynamic_meta_description<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$rawcontent</span> <span style="color: #339933;">=</span> 	get_the_content<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$rawcontent</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$rawcontent</span> <span style="color: #339933;">=</span> <span style="color: #990000;">htmlentities</span><span style="color: #009900;">&#40;</span>bloginfo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'description'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$rawcontent</span> <span style="color: #339933;">=</span> apply_filters<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'the_content_rss'</span><span style="color: #339933;">,</span> <span style="color: #990000;">strip_tags</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$rawcontent</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$rawcontent</span> <span style="color: #339933;">=</span> <span style="color: #990000;">preg_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/\[.+\]/'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> <span style="color: #000088;">$rawcontent</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$chars</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\r</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;chr(13)&quot;</span><span style="color: #339933;">,</span>  <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\t</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;<span style="color: #660099; font-weight: bold;">\0</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;<span style="color: #660099; font-weight: bold;">\x0B</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$rawcontent</span> <span style="color: #339933;">=</span> <span style="color: #990000;">htmlentities</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$chars</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot; &quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$rawcontent</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">strlen</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$rawcontent</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">155</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$rawcontent</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$desc</span> <span style="color: #339933;">=</span> <span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$rawcontent</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">155</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #000088;">$desc</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></td></tr></table></div>

<p>This little script grabs the raw content using <code>get_the_content()</code>, then it applies some filters and removes shortcodes, tags and line breaks. Once that is done, it limits the description to 155 characters if it is too long. Finally it returns the description, formatted exactly how you need it to be.</p>
<p>Next all we need to do is add a line to the <code>header.php</code> between the head tags.</p>

<div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="php" style="font-family:monospace;">&lt;meta name=&quot;description&quot; content=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> dynamic_meta_description<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; /&gt;</pre></div></td></tr></table></div>

<p>If a meta description line already exists, you can replace it with this. </p>
<p>Now all of your pages will have a unique meta description, and those that don&#8217;t will have your default site description, which you set up in your wp-admin under your General Settings.</p>
]]></content:encoded>
			<wfw:commentRss>http://bavotasan.com/2010/meta-descriptions-wordpress/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Simple Voting for WordPress with PHP and jQuery</title>
		<link>http://bavotasan.com/2009/simple-voting-for-wordpress-with-php-and-jquery/</link>
		<comments>http://bavotasan.com/2009/simple-voting-for-wordpress-with-php-and-jquery/#comments</comments>
		<pubDate>Fri, 18 Dec 2009 17:58:03 +0000</pubDate>
		<dc:creator>c.bavota</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[Lt]]></category>
		<category><![CDATA[Meta]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[span]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[Wp]]></category>

		<guid isPermaLink="false">http://bavotasan.com/?p=1567</guid>
		<description><![CDATA[This tutorial is no longer up-to-date. Please check out A Better Voting System for WordPress for a more secure and efficient approach. I needed to create a simple way for site members to vote on a post and the few scripts I found didn&#8217;t really work how I needed them to. So I decided to [...]]]></description>
			<content:encoded><![CDATA[<div class="imgprov">
This tutorial is no longer up-to-date. Please check out <a href="http://bit.ly/rrp67O">A Better Voting System for WordPress</a> for a more secure and efficient approach.
</div>
<p>I needed to create a simple way for site members to vote on a post and the few scripts I found didn&#8217;t really work how I needed them to. So I decided to whip something together myself. I developed a pretty basic script using PHP and jQuery to allow members who are signed in to click on a simple link to add their vote to a post.<br />
<span id="more-1567"></span><br />
First you need to add this to your <code>header.php</code> file between the &lt;head&gt; tags. If you notice that you already have the <code>&lt;?php wp_head(); ?&gt;</code> call somewhere else in your <code>header.php</code> file, just delete it.</p>

<div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="javascript" style="font-family:monospace;">&lt;?php wp_enqueue_script( 'jquery' ) ?&gt;
&lt;?php wp_head(); ?&gt;
<span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span>
jQuery<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
jQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.vote a&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span>
<span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #003366; font-weight: bold;">var</span> some <span style="color: #339933;">=</span> jQuery<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> thepost <span style="color: #339933;">=</span> jQuery<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;post&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> theuser <span style="color: #339933;">=</span> jQuery<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;user&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
jQuery.<span style="color: #660066;">post</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;&lt;?php bloginfo('template_url'); ?&gt;/vote.php&quot;</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span>user<span style="color: #339933;">:</span> theuser<span style="color: #339933;">,</span> post<span style="color: #339933;">:</span> thepost<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> 
<span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>data<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #003366; font-weight: bold;">var</span> votebox <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;.vote&quot;</span><span style="color: #339933;">+</span>thepost<span style="color: #339933;">+</span><span style="color: #3366CC;">&quot; span&quot;</span><span style="color: #339933;">;</span>
jQuery<span style="color: #009900;">&#40;</span>votebox<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">text</span><span style="color: #009900;">&#40;</span>data<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
jQuery<span style="color: #009900;">&#40;</span>some<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">replaceWith</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&lt;span class=&quot;voted&quot;&gt;Voted&lt;/span&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>	
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></div></td></tr></table></div>

<p>When a member clicks on the vote link, the above code will get the post ID and the member&#8217;s user ID and send it to a file called <code>vote.php</code> using a post method. The vote.php file will perform everything we need to add the vote.</p>
<p>So let&#8217;s create a file called <code>vote.php</code> and add it to your theme&#8217;s directory.</p>

<div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$file</span> <span style="color: #339933;">=</span> <span style="color: #990000;">dirname</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">__FILE__</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$file</span> <span style="color: #339933;">=</span> <span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #990000;">stripos</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;wp-content&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">require</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$file</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;/wp-load.php&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$currentvotes</span> <span style="color: #339933;">=</span> get_post_meta<span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'post'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'votes'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$currentvotes</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$currentvotes</span> <span style="color: #339933;">+</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$voters</span> <span style="color: #339933;">=</span> get_post_meta<span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'post'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'thevoters'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$voters</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$voters</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'user'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">else</span> <span style="color: #000088;">$voters</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$voters</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;,&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'user'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
update_post_meta<span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'post'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'votes'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$currentvotes</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
update_post_meta<span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'post'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'thevoters'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$voters</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$currentvotes</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></td></tr></table></div>

<p>Once the information is posted to <code>vote.php</code> two custom fields are created. One to count the vote and one to add the voter to a list so that they can&#8217;t vote again.</p>
<p>Add the code below to your <code>functions.php</code> file, or create a <code>functions.php</code> file if your theme does not have one.</p>

<div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// voting function</span>
<span style="color: #000000; font-weight: bold;">function</span> voting<span style="color: #009900;">&#40;</span><span style="color: #000088;">$id</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$user_ID</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$currentvotes</span> <span style="color: #339933;">=</span> get_post_meta<span style="color: #009900;">&#40;</span><span style="color: #000088;">$id</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'votes'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$voters</span> <span style="color: #339933;">=</span> get_post_meta<span style="color: #009900;">&#40;</span><span style="color: #000088;">$id</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'thevoters'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$voters</span> <span style="color: #339933;">=</span> <span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;,&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$voters</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$voters</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$voter</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$voter</span> <span style="color: #339933;">==</span> <span style="color: #000088;">$user_ID</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$alreadyVoted</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$currentvotes</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$currentvotes</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;div class=&quot;vote vote'</span><span style="color: #339933;">.</span><span style="color: #000088;">$id</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot;&gt;&lt;span&gt;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$currentvotes</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;/span&gt;'</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$user_ID</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #339933;">!</span><span style="color: #000088;">$alreadyVoted</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;br /&gt;&lt;a post=&quot;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$id</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot; user=&quot;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$user_ID</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot;&gt;'</span><span style="color: #339933;">.</span>__<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Vote&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;/a&gt;'</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$user_ID</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$alreadyVoted</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;br /&gt;&lt;span class=&quot;voted&quot;&gt;'</span><span style="color: #339933;">.</span>__<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Voted&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;/span&gt;'</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;/div&gt;'</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$user_ID</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;div class=&quot;signup&quot;&gt;&lt;p&gt;&lt;a href=&quot;'</span><span style="color: #339933;">.</span>get_bloginfo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'url'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'/wp-login.php?action=register&quot;&gt;'</span><span style="color: #339933;">.</span>__<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Register'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;/a&gt; '</span><span style="color: #339933;">.</span>__<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'to vote'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'.&lt;/p&gt;&lt;/div&gt;'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></td></tr></table></div>

<p>Let&#8217;s add some CSS to style our voting box.</p>

<div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #6666ff;">.vote</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #933;">5px</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#eee</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#ddd</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">width</span> <span style="color: #00AA00;">:</span><span style="color: #933;">50px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">text-align</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">center</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span> <span style="color: #933;">10px</span> <span style="color: #993333;">auto</span><span style="color: #00AA00;">;</span>
	<span style="color: #00AA00;">&#125;</span>
&nbsp;
	<span style="color: #6666ff;">.vote</span> a<span style="color: #00AA00;">,</span> <span style="color: #6666ff;">.vote</span> span<span style="color: #6666ff;">.voted</span> <span style="color: #00AA00;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">cursor</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">pointer</span><span style="color: #00AA00;">;</span>
		<span style="color: #000000; font-weight: bold;">margin-top</span><span style="color: #00AA00;">:</span> <span style="color: #933;">5px</span><span style="color: #00AA00;">;</span>
		<span style="color: #000000; font-weight: bold;">padding-top</span><span style="color: #00AA00;">:</span> <span style="color: #933;">5px</span><span style="color: #00AA00;">;</span>
		<span style="color: #000000; font-weight: bold;">border-top</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#ddd</span><span style="color: #00AA00;">;</span>
		<span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">block</span><span style="color: #00AA00;">;</span>
		<span style="color: #00AA00;">&#125;</span>
&nbsp;
	<span style="color: #6666ff;">.vote</span> span<span style="color: #6666ff;">.voted</span> <span style="color: #00AA00;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">cursor</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">default</span><span style="color: #00AA00;">;</span>
		<span style="color: #00AA00;">&#125;</span></pre></div></td></tr></table></div>

<p>Now all you need to do is add the following within the WordPress loop to have the voting box appear.</p>

<div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> voting<span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></td></tr></table></div>

<p>Test it out below:</p>
<p><script type="text/javascript">
jQuery(document).ready(function(){
	jQuery(".vote a").click(
		function() {
		var some = jQuery(this);
		var votebox = ".vote span";
		jQuery(votebox).text(1);
		jQuery(some).replaceWith('<span class="voted">Voted</span>');
	});
});	
</script></p>
<div class="vote"><span>0</span><br />
<a>Vote</a>
</div>
]]></content:encoded>
			<wfw:commentRss>http://bavotasan.com/2009/simple-voting-for-wordpress-with-php-and-jquery/feed/</wfw:commentRss>
		<slash:comments>41</slash:comments>
		</item>
		<item>
		<title>Remove the WordPress Generator</title>
		<link>http://bavotasan.com/2009/remove-the-wordpress-generator/</link>
		<comments>http://bavotasan.com/2009/remove-the-wordpress-generator/#comments</comments>
		<pubDate>Mon, 10 Aug 2009 15:45:41 +0000</pubDate>
		<dc:creator>c.bavota</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[content]]></category>
		<category><![CDATA[file]]></category>
		<category><![CDATA[folder]]></category>
		<category><![CDATA[Hackers]]></category>
		<category><![CDATA[line]]></category>
		<category><![CDATA[Lt]]></category>
		<category><![CDATA[Meta]]></category>
		<category><![CDATA[name]]></category>
		<category><![CDATA[Php]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[site]]></category>
		<category><![CDATA[text]]></category>
		<category><![CDATA[theme]]></category>
		<category><![CDATA[version]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[Wp]]></category>

		<guid isPermaLink="false">http://bavotasan.com/?p=850</guid>
		<description><![CDATA[WordPress automatically places a line of text between your &#60;head&#62; tags which states the version you currently have installed. I have read that it is there for statistical reasons which is all fine and dandy, but sometimes showing off which version of WP you are using lets hackers know exactly what vulnerabilities your site has. [...]]]></description>
			<content:encoded><![CDATA[<p>WordPress automatically places a line of text between your &lt;head&gt; tags which states the version you currently have installed. I have read that it is there for statistical reasons which is all fine and dandy, but sometimes showing off which version of WP you are using lets hackers know exactly what vulnerabilities your site has. </p>
<p>For security reasons, I suggest removing the generator, and doing so only takes one line of code.<br />
<span id="more-850"></span><br />
The WordPress generator line looks like this:</p>
<p><code>&lt;meta name="generator" content="WordPress 2.8" /&gt;</code></p>
<p>To get rid of it, open up your functions.php file. It is located in your theme&#8217;s folder. If there is no functions.php file, create one and just add the following code.</p>

<div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="php" style="font-family:monospace;">remove_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'wp_head'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'wp_generator'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></td></tr></table></div>

<p>Be sure to place it between &lt;?php&gt;&lt;?&gt; tags.</p>
]]></content:encoded>
			<wfw:commentRss>http://bavotasan.com/2009/remove-the-wordpress-generator/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Using WP_Query to Fetch Posts in WordPress</title>
		<link>http://bavotasan.com/2009/using-wp_query-to-fetch-posts-in-wordpress/</link>
		<comments>http://bavotasan.com/2009/using-wp_query-to-fetch-posts-in-wordpress/#comments</comments>
		<pubDate>Wed, 28 Jan 2009 18:00:02 +0000</pubDate>
		<dc:creator>c.bavota</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[category]]></category>
		<category><![CDATA[client]]></category>
		<category><![CDATA[excerpt]]></category>
		<category><![CDATA[left]]></category>
		<category><![CDATA[loop]]></category>
		<category><![CDATA[Lt]]></category>
		<category><![CDATA[Meta]]></category>
		<category><![CDATA[page]]></category>
		<category><![CDATA[Php]]></category>
		<category><![CDATA[post]]></category>
		<category><![CDATA[problem]]></category>
		<category><![CDATA[query]]></category>
		<category><![CDATA[Query Function]]></category>
		<category><![CDATA[Sidebar]]></category>
		<category><![CDATA[the loop]]></category>
		<category><![CDATA[way]]></category>
		<category><![CDATA[Widget]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[Wordpress loop]]></category>
		<category><![CDATA[Wp]]></category>
		<category><![CDATA[wp_query]]></category>

		<guid isPermaLink="false">http://bavotasan.com/?p=177</guid>
		<description><![CDATA[I was just putting together a WordPress widget for a client and I came across a small road block. I was using &#60;?php query_post(); ?&#62; to set the loop to act the way I needed it to but when the widget loaded up in the left sidebar, it caused some issues when going to a [...]]]></description>
			<content:encoded><![CDATA[<p>I was just putting together a WordPress widget for a client and I came across a small road block. I was using <code>&lt;?php query_post(); ?&gt;</code> to set the loop to act the way I needed it to but when the widget loaded up in the left sidebar, it caused some issues when going to a category page. The problem was the query I initialized in the sidebar was carrying over to the main section. I couldn&#8217;t figure out what to do until I stumbled up the wp_query function.<br />
<span id="more-177"></span><br />
It works in a similar way to query_post but you need to do a few minor things to get it to work properly.</p>

<div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$featuredPosts</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> WP_Query<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$featuredPosts</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">query</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'showposts=5&amp;cat=3'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$featuredPosts</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">have_posts</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #000088;">$featuredPosts</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">the_post</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;h1&gt;&lt;a href=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> the_permalink<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot;&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> the_title<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/a&gt;&lt;/h1&gt;
&lt;div class=&quot;meta&quot;&gt;
By <span style="color: #000000; font-weight: bold;">&lt;?php</span> the_author<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;/div&gt;
&lt;div class=&quot;storycontent&quot;&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> the_excerpt<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;/div&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endwhile</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></td></tr></table></div>

<p>First you need to setup the query.</p>

<div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$featuredPosts</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> WP_Query<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$featuredPosts</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">query</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'showposts=5&amp;cat=3'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></td></tr></table></div>

<p>Then you need to setup the loop.</p>

<div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="php" style="font-family:monospace;">while ($featuredPosts-&gt;have_posts()) : $featuredPosts-&gt;the_post(); ?&gt;
     (stuff goes here)
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endwhile</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></td></tr></table></div>

<p>So in the end it looks something like this.</p>

<div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$featuredPosts</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> WP_Query<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$featuredPosts</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">query</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'showposts=5&amp;cat=3'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$featuredPosts</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">have_posts</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #000088;">$featuredPosts</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">the_post</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;h1&gt;&lt;a href=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> the_permalink<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot;&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> the_title<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/a&gt;&lt;/h1&gt;
&lt;div class=&quot;meta&quot;&gt;
By <span style="color: #000000; font-weight: bold;">&lt;?php</span> the_author<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;/div&gt;
&lt;div class=&quot;storycontent&quot;&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> the_excerpt<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;/div&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endwhile</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></td></tr></table></div>

<p>What this will do is get 5 posts from category 3 and list them, without interfering with other loops or queries on your site.</p>
]]></content:encoded>
			<wfw:commentRss>http://bavotasan.com/2009/using-wp_query-to-fetch-posts-in-wordpress/feed/</wfw:commentRss>
		<slash:comments>22</slash:comments>
		</item>
	</channel>
</rss>

