<?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>Notebook &#187; Wordpress</title>
	<atom:link href="http://www.mikemattner.com/tag/wordpress/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.mikemattner.com</link>
	<description></description>
	<lastBuildDate>Tue, 27 Jul 2010 16:52:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Overwriting WordPress&#160;Functions</title>
		<link>http://www.mikemattner.com/2010/01/overwriting-wordpress-functions/</link>
		<comments>http://www.mikemattner.com/2010/01/overwriting-wordpress-functions/#comments</comments>
		<pubDate>Sat, 16 Jan 2010 06:14:59 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[Entries]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[Web Design]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://www.mikemattner.com/?p=1348</guid>
		<description><![CDATA[WordPress finds new ways to amaze me; some of these things are neither impressive nor particularly noteworthy, except that these things enable users to customize this platform in ways unimaginable to regular Joe Blogger, who simply uses the system. And in spite of how common such things are to those who truly dive into it, [...]]]></description>
			<content:encoded><![CDATA[<p>WordPress finds new ways to amaze me; some of these things are neither impressive nor particularly noteworthy, except that these things enable users to customize this platform in ways unimaginable to regular Joe Blogger, who simply uses the system. And in spite of how common such things are to those who truly dive into it, I struggled for quite a while trying to find the best way to change a bit of core functionality.</p>
<div class="pull-4 span-4 pull-text"><strong>Note:</strong> I want to caution you to avoid doing anything with WordPress&#8217; core functions if you aren&#8217;t familiar with php. You will regret it, especially if you&#8217;ve done something directly to a core file. Stick with filtering and extending with plugins.</div>
<p>If you scroll down to the bottom of the site on the home page, and on any entry page, you&#8217;ll notice a set of buttons that will help you navigate to the next and previous entries, or the next and previous pages of the home page. I needed a way to style these, and oddly enough WordPress did not provide a class name for either of those links. Too bad. So I needed to find out how to adjust that in order to target those links. In addition to that, I needed to also make a small change that classes wouldn&#8217;t have allowed for, which was to get the function to output code for the cases in which there were no other pages or posts in a given direction. My first thought was to find whatever core file these functions were located in and then make the change there; I proceeded to do this, got it working, and decided that I should go about this in a different way if I ever wanted to upgrade without having to change that file every time&#8211;if I even remembered in those instances.</p>
<p>The tags in question were: <code>next_posts_link</code>, <code>previous_posts_link</code>, <code>next_post_link</code>, and <code>previous_post_link</code>, as well as a few more functions that were related to them. Each of these provides the basic functionality I needed to modify; I tried to replicate these functions, using the same name, in an effort to essentially overwrite the original WordPress core functions. Well, I located them in the link-template.php file, copied and pasted them into my themes functions.php file, and proceeded to make the necessary changes. When I uploaded functions.php and refreshed my site, I had a big giant error; actually it was less an error and more a blank screen, which is worse in a lot of ways as you have no idea what went wrong. I should have known from my programming experience that I couldn&#8217;t duplicate these functions in this way.</p>
<p>I was stumped for the longest time, and search after search on Google was leading me towards something called, <code>add_filter</code>, which it turns out doesn&#8217;t quite overwrite the function so much as filter the function results through your new function; this was not what I wanted to do on any level. I couldn&#8217;t manipulate the data through a filter to achieve the needed results.</p>
<p>After some time, and a lot of searching, I landed on a WordPress MU forum (still not sure what MU is), that gave me my answer&#8211;the most obvious answer&#8211;which was to take the functions I needed and rename them. I could then use those new function names in place of the old ones wherever I needed them in my theme files.</p>
<p>That&#8217;s easy, ain&#8217;t it? Why don&#8217;t people explain this more often, or even need to to do this enough for it to be found on Google?</p>
<p><strong>Update 1/19/2010</strong>: I wanted to clarify just in case some one stumbled upon this looking for an actual bit of code that might show them what I was up to. So here goes.</p>
<p>Instead of adding a filter to the function you want to change:</p>
<div class="pull-4 span-18">
<div class="code">
<pre><code>add_filter('next_posts_link', 'new_next_posts_link', 0);</code></pre>
</div>
</div>
<p>Add a new function to functions.php and call it in your template wherever you were going to use the old one.</p>
<div class="pull-4 span-18">
<div class="code">
<pre><code>function new_get_next_posts_link( $label = 'Next Page &amp;raquo;', $max_page = 0 ) {
    global $paged, $wp_query;

    if ( !$max_page ) {
        $max_page = $wp_query-&gt;max_num_pages;
    }

    if ( !$paged )
    $paged = 1;

    $nextpage = intval($paged) + 1;

    if ( !is_single() ) {
        if( empty($paged) || $nextpage &lt;= $max_page) {
            $attr = apply_filters( 'next_posts_link_attributes', '' );
            return '&lt;a href="' . next_posts( $max_page, false ) . "\" class=\"next\" $attr&gt;". preg_replace('/&amp;([^#])(?![a-z]{1,8};)/', '&amp;#038;$1', $label) .'&lt;/a&gt;';
        } else {
            $attr = apply_filters( 'next_posts_link_attributes', '' );
            return '&lt;span '.$attr.'&gt;'. preg_replace('/&amp;([^#])(?![a-z]{1,8};)/', '&amp;#038;$1', $label) .'&lt;/span&gt;';
        }
    }
}
function new_next_posts_link( $label = 'Next Page &amp;raquo;', $max_page = 0 ) {
    echo new_get_next_posts_link( $label, $max_page );
}﻿</code></pre>
</div>
</div>
<p>I&#8217;ve essentially adjusted this line:</p>
<div class="pull-4 span-18">
<div class="code">
<pre><code>if ( !is_single() &amp;&amp; ( empty($paged) || $nextpage &lt;= $max_page) ) {
    $attr = apply_filters( 'next_posts_link_attributes', '' );
    return '&lt;a href="' . next_posts( $max_page, false ) . "\" $attr&gt;". preg_replace('/&amp;([^#])(?![a-z]{1,8};)/', '&amp;#038;$1', $label) .'&lt;/a&gt;';
}﻿</code></pre>
</div>
</div>
<p>And changed it to this next bit in order to add a class to the link for styling purposes as well as to display a grayed out link if there was no next (or previous in the case of those set of functions) page.</p>
<div class="pull-4 span-18">
<div class="code">
<pre><code>if ( !is_single() ) {
    if( empty($paged) || $nextpage &lt;= $max_page) {
        $attr = apply_filters( 'next_posts_link_attributes', '' );
        return '&lt;a href="' . next_posts( $max_page, false ) . "\" class=\"next\" $attr&gt;". preg_replace('/&amp;([^#])(?![a-z]{1,8};)/', '&amp;#038;$1', $label) .'&lt;/a&gt;';
    } else {
        $attr = apply_filters( 'next_posts_link_attributes', '' );
        return '&lt;span '.$attr.'&gt;'. preg_replace('/&amp;([^#])(?![a-z]{1,8};)/', '&amp;#038;$1', $label) .'&lt;/span&gt;';
    }
}</code></pre>
</div>
</div>
<p>So, again. If you&#8217;ve got something to modify, do it this way. The functions.php template file is your best friend.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mikemattner.com/2010/01/overwriting-wordpress-functions/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Adding Articles and Upgrading&#160;WordPress</title>
		<link>http://www.mikemattner.com/2009/07/adding-articles-and-upgrading-wordpress/</link>
		<comments>http://www.mikemattner.com/2009/07/adding-articles-and-upgrading-wordpress/#comments</comments>
		<pubDate>Fri, 17 Jul 2009 17:34:11 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[Entries]]></category>
		<category><![CDATA[Articles]]></category>
		<category><![CDATA[Site Issues]]></category>
		<category><![CDATA[Upgrade]]></category>
		<category><![CDATA[Web Design]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://www.mikemattner.com/?p=937</guid>
		<description><![CDATA[I&#8217;ve spent a little bit of time over the past few days (don&#8217;t worry, I&#8217;m still working on your wordpress template!) creating a brand new category of entries: articles. Articles are those longer entries that I really just want to add a bit of style to, something that breaks the regular layout, or something that [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve spent a little bit of time over the past few days (don&#8217;t worry, I&#8217;m still working on your wordpress template!) creating a brand new category of entries: articles. Articles are those longer entries that I really just want to add a bit of style to, something that breaks the regular layout, or something that I found I wanted to do but was limited by the entry layout.</p>
<p>You won&#8217;t see these too often, but when you do, they should be decent. You can identify them by the <strong>&sect;</strong> icon next to them.</p>
<p>On another note, while getting my hands dirty messing around with the article format, and simultaneously reading about a brand new exploit to WordPress (no relevance I hope), my admin section started to act a bit funky. I decided that I needed to upgrade in order to save the damn thing. It worked, and I&#8217;m now fully upgraded to the latest version.</p>
<p>I made the mistake of turning off the pesky upgrade notification, because I thought, hey, I just got this version, it works, why bother? Don&#8217;t do that. Just upgrade when the next version updates.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mikemattner.com/2009/07/adding-articles-and-upgrading-wordpress/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Spammy&#160;Comments</title>
		<link>http://www.mikemattner.com/2009/05/spammy-comments/</link>
		<comments>http://www.mikemattner.com/2009/05/spammy-comments/#comments</comments>
		<pubDate>Tue, 26 May 2009 16:19:43 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[Entries]]></category>
		<category><![CDATA[Spam]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://www.mikemattner.com/?p=396</guid>
		<description><![CDATA[I&#8217;ve noticed an inordinate amount of spam comments coming in over the lines lately; most from a user name like Free-I-Phones-and-how-to-get-them. They are not immediately published, of course, but they still come through. If anyone works with WordPress and knows of an excellent spam prevention plug in, let me know.]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve noticed an inordinate amount of spam comments coming in over the lines lately; most from a user name like Free-I-Phones-and-how-to-get-them. They are not immediately published, of course, but they still come through.</p>
<p>If anyone works with WordPress and knows of an excellent spam prevention plug in, <a href="http://www.mikemattner.com/information/">let me know</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mikemattner.com/2009/05/spammy-comments/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>&#8216;Upgrading&#8217; to&#160;WordPress</title>
		<link>http://www.mikemattner.com/2009/05/upgrading-to-wordpress/</link>
		<comments>http://www.mikemattner.com/2009/05/upgrading-to-wordpress/#comments</comments>
		<pubDate>Fri, 15 May 2009 15:59:43 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[Entries]]></category>
		<category><![CDATA[Upgrade]]></category>
		<category><![CDATA[Web Design]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://www.mikemattner.com/notebook/?p=30</guid>
		<description><![CDATA[I am currently in the process of upgrading my website. All over. From the portfolio, to the tumble-log-like blog. What prompted this most recent redesign? Well, on top of never being happy with one&#8217;s own work, I was particularly unhappy with the blandness of the previous design, plus&#8230;WordPress. I discovered the joys of using WordPress. [...]]]></description>
			<content:encoded><![CDATA[<p>I am currently in the process of upgrading my website. All over. From the portfolio, to the tumble-log-like blog. What prompted this most recent redesign? Well, on top of never being happy with one&#8217;s own work, I was particularly unhappy with the blandness of the previous design, plus&#8230;WordPress.</p>
<p>I discovered the joys of using WordPress. I always felt like I had to hack through MovableType&#8217;s templating system, but with this I could actually build something using php. That&#8217;s something I can appreciate a great deal.</p>
<p>At this moment, however, I am manually transferring all of the links, quotes, and entries that I can. It is a LONG process. And of course one that is next to impossible to accomplish. I cannot simply import all of my old entries, although that seems to be what I need to do, because when I did so, it was not too successful. I may give it a try again, but it&#8217;s going to take some time to get it done right. Time that I have I suppose.</p>
<p>Oh well.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mikemattner.com/2009/05/upgrading-to-wordpress/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>WordPress vs MovableType: My&#160;Experience</title>
		<link>http://www.mikemattner.com/2009/04/wordpress-vs-movabletype-my-experience/</link>
		<comments>http://www.mikemattner.com/2009/04/wordpress-vs-movabletype-my-experience/#comments</comments>
		<pubDate>Wed, 29 Apr 2009 15:40:07 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[Entries]]></category>
		<category><![CDATA[Movable Type]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[Web Design]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://www.mikemattner.com/notebook/?p=22</guid>
		<description><![CDATA[I’ve been working on a bit of a personal project lately and decided the easiest and best way to introduce a blog would be to install WordPress, plus I really wanted to give that system a little more of a try than I had in the past. My gut reaction upon installing and settling on [...]]]></description>
			<content:encoded><![CDATA[<p>I’ve been working on a bit of a personal project lately and decided the easiest and best way to introduce a blog would be to install WordPress, plus I really wanted to give that system a little more of a try than I had in the past.</p>
<p>My gut reaction upon installing and settling on a theme for modification was that this was REALLY easy to work with and highly customizable. I had, in fact, gotten used to working with my own MovableType installation, its quirks, and its own templating system, but the php based WordPress on my server was a breeze to deal with compared to the former. It was faster, offered better plugins, easier templating, and I could even edit the hell out of those plugins to customize the installation even further for my needs.</p>
<p>I’m so convinced by my experience that WordPress is the superior publishing platform for anyone looking to get started beyond the free services and put up a site on their own domain, that I am absolutely going to develop the next iteration of this site with WordPress in mind.</p>
<p>MovableType has been good to me, and it truly is a very powerful platform, but my servers don’t deal with it, and it is SLOW as a result. Plus, all of the plugins I want to use aren’t offered for MT or don’t offer what I need. And that can be frustrating.</p>
<p>What I like about MT, though, is the publishing experience. I feel like I can easily add tags to any entry with little problem, and the interface (MT 4.0+ at least) is minimal and easy to use. Previous versions were a bear to work with, I’m afraid, but 4.0+ is quite fantastic.</p>
<p>Anyway, my conclusion: WordPress for the future iteration, but MT will suffice for now; WordPress is superior to MT for beginners and its ease of use; and MT is not likely to catch up.</p>
<p><em><strong>Update:</strong> 5/15/09 I am currently in the process of converting to WordPress. Manually. Really frustrating, but worthwhile. I&#8217;ve also discovered that it is a superior publishing experience.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.mikemattner.com/2009/04/wordpress-vs-movabletype-my-experience/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
