Tag: customize

Critical Review of Dyasonhat’s Premium Smart Sort WordPress Plugin

Posted on January 17, 2009 in WordPress by Jeff Starr

After hearing about the recently released “premium” version of Dyasonhat’s Smart Sort Plugin for WordPress, I just had to give it a try. Occasionally working on projects requiring customized ordering of posts, I like to keep my utility belt well-equipped with any plugins or code techniques that will facilitate the process of man-handling post order. In this article, I discuss my experience with WP Smart Sort Premium.

Continue Reading

WordPress Custom Fields, Part II: Tips and Tricks

Posted on December 22, 2008 in WordPress by Jeff Starr

[ Diagram: Electric Field ] As we have seen in our previous post, WordPress Custom Fields Part I, custom fields provide an excellent way to add flexible content to your posts and pages. By assigning various types of content to different custom fields, you gain complete control over when, where, and how to display the associated information. For example, sub-headings may be displayed in the sidebar, footnotes may be consolidated into a single region, post images may be displayed before the post title, and so on. In this follow-up article, we will review the basics of custom fields and then jump into a few custom-field tips and tricks.

Continue Reading

WordPress Custom Fields, Part I: The Basics

Posted on December 17, 2008 in WordPress by Jeff Starr

[ Diagram: Electric Field ] I recently developed a theme that makes heavy use of WordPress’ custom fields. The custom-field functionality of WordPress makes it possible to rig up just about any customized layout quickly and easily. Custom fields enable designers to organize post content into different sections, making it possible to create non-linear page layouts, with different types of content easily removed from the normal post loop and relocated to different parts of the document. This organizational and design flexibility has the added benefit of making it super-easy to update your content, redesign your theme, and handle blog maintenance in general. In the first part of this mini-series, we walk through the process of implementing and using custom fields; then, in part two, I will share some delicious tips and tricks to help you get the most out of everything that custom fields have to offer.

Continue Reading

Custom HTTP Errors via htaccess

Posted on March 18, 2008 in Function by Jeff Starr

We all know how important it is to deliver sensible, helpful 404 error pages to our visitors. There are many ways of achieving this functionality, including the well-known htaccess trick used to locally redirect users to custom error pages:

# htaccess custom error pages
ErrorDocument 400 /errors/400.html
ErrorDocument 401 /errors/401.html
ErrorDocument 403 /errors/403.html
ErrorDocument 404 /errors/404.html
ErrorDocument 500 /errors/500.html

..and so on. These directives basically tell Apache to deliver the designated documents for their associated error types. Many webmasters and developers employ this trick to ensure that visitors receive customized error pages that are generally more user-friendly or design-specific than the rather unfriendly Apache defaults. Serving custom error pages is an excellent way to enhance overall site usability and accessibility, but there are several other useful techniques to consider as well.

Continue Reading

WordPress Tip: Careful with that Autosave, Eugene

Posted on March 17, 2008 in WordPress by Jeff Starr

After upgrading WordPress from version 2.0.5 to 2.3.3, I did some experimenting with the “post autosave” feature. The autosave feature uses some crafty ajax to automagically save your post every 2 minutes (120 seconds by default). Below the post-editing field, you will notice a line of text that displays the time of the most recent autosave, similar to the following:

[ Screenshot: WordPress Autosave Message (Saved at 2:34:02.) ]

Surely, this relatively new feature provides an added layer of protection against lost work, but all is not perfect (yet) in the world of automatically saved content.

Several months ago, I lost several hours of work because the autosave feature completely failed to work, despite the periodically reassuring “Saved at..” message. After working for several hours with a false sense of security, WordPress choked and my post had vanished. In shock, I scoured the database for any trace of my recent efforts, but to no avail. The entire post had disappeared into the void. Utterly devastated and disillusioned, I decided to investigate the so-called “autosave” feature, learn what had happened, and take steps to avoid such travesty in the future. Here is a summary of my investigation..

Continue Reading

6 Ways to Customize WordPress Post Order

Posted on January 22, 2008 in WordPress by Jeff Starr

[ Graphic: Inverted Triangular Fractal ] Recently, reader Luke Knowles asked how to customize the sort order of his posts in WordPress. Looking into a solution to this question proved quite enlightening. Within moments I was able to discern 4 methods for modifying post order, and then several days later I discovered 2 additional custom sorting techniques. After updating the reply to Luke’s comment, it seemed like some good information that other WordPressers may find useful. So, here are six ways to customize the sort order of posts in WordPress..

Continue Reading

Important Note for Your Custom Error Pages

Posted on January 21, 2008 in Websites by Jeff Starr

Just a note to web designers and code-savvy bloggers: make sure your custom error pages are big enough for the ever-amazing <cough> Internet Explorer browser. If your custom error pages are too small, IE will take the liberty of serving its own proprietary web page, replete with corporate linkage and poor grammar.

How big, baby?

Well, that’s a good question. In order for users of Internet Explorer to enjoy your carefully crafted custom error pages, they need to exceed 512 bytes in size. Using proper doctype markup, your custom pages should include more than around 10 lines (roughly) of additional markup and/or content. A good rule of thumb is to throw down at least a couple of decent-sized chunks of code. If you are going for a minimalist set of custom error pages and need a way to increase overall page size, you can always add a paragraph or two of good ‘ol Lorem Ipsum text as a comment in the markup:

Continue Reading

WordPress Core Hacks Used at Perishable Press

Posted on December 3, 2007 in Perishable, WordPress by Jeff Starr

One of the necessary evils associated with creating a highly customized WordPress-powered site involves the inevitable necessity to hack the WordPress core. WordPress is built for mass-consumption and tends to cater to the largest audience possible, making it necessary to bend and poke around the corners to get WordPress to function in a more specific or specialized capacity.

Of course, there is a major downside to tweaking core WordPress files: upgrading. The overambitious WordPress peeps are constantly rolling out upgrade after upgrade, many of which are required security fixes, patches, or whatever. The point is that editing the WordPress core on your current version of WordPress requires that you edit each and every subsequent upgrade, for each and every one of your sites.

Over time, I have realized the importance of documenting core changes for any sites that require them. Having a concise record of the files and code involved with each hack greatly facilitates the entire upgrade process. Without such a reference, subtle changes may be forgotten and key hacks may be overlooked. Here at Perishable Press, my former Core Hacks Log served me well from WordPress 1.5 to 2.0, however, much of it no longer applies to the new WordPress 2.3 configuration. Since the latest site overhaul, I have dramatically reduced the overall number of required core edits.

Continue Reading

Standards-Compliance Throwdown: MS-IE5/6 DNS/404 Error-Page Redesign

Posted on May 1, 2007 in Presentation, Standards by Jeff Starr

Screenshot: default IE 404 error page
Default DNS Error page for Internet Explorer

First of all, congratulations if you are geeky enough to understand the title of this article. Many would be like, "CSS, MS.. IE, error ..what..?" Whatever. If you get the title, you will get the point of this utterly pointless exercise. If that is the case, prepare for a delightful romp through geekland. Otherwise, save your precious time and stop reading here (exit strategy).

Well, okay, for the seriously unenlightened, let us explain the object of our present focus:

The default "DNS Error" page for Internet Explorer unfortunately remains a familiar sight for millions of Microsoft users. Typically, the default MS DNS Error page loads whenever a browser is unable to connect to the internet or other networked resource. Once loaded, the error page announces itself with a message that reads "The page cannot be displayed." The page then presents several options: refresh browser, retype address, check connection, check configuration, etc.     — Monzilla Media (i.e., me)

Still interested? Well, okay. Actually, it’s no big deal. Just a nice, standards-compliant, CSS-based redesign of that old, nappy Internet Explorer 404 Error page. You know the one. Whenever you can’t connect to the internet, it jumps up at you, sticks out it’s tongue and mocks you. Yes, we hate it, too. But alas, with the release of Internet Explorer 7 comes a ‘brand new’ 404 error page. Surely, it’s just a matter of time before that dumpy old 404 error page circa IE5/6 disappears forever. So, before that tragedy unfolds..

Continue Reading

Rename the Recycle Bin in WinXP

Posted on January 16, 2007 in Technology by Jeff Starr

To rename the Recycle Bin in Windows XP, create a new text.txt file in your favorite directory and add the following lines:

REGEDIT4
[HKEY_CLASSES_ROOT\CLSID\{645FF040-5081-101B-9F08-00AA002F954E}\ShellFolder]
"Attributes"=hex:50,01,00,20"CallForAttributes"=dword:00000000

Next, rename the file extension from ".txt" to ".reg" — the other part of the file name may be whatever you prefer (e.g., RecycleBin.reg). Then, double-click the file to have Windows import it into the Registry. Now go right-click your Recycle Bin and use the new option to Rename it.

To remove renaming functionality for the Recycle Bin, replicate the same file you created initially, and replace the last line (i.e., the third line) with the following:

"Attributes"=hex:40,01,00,20"CallForAttributes"=dword:00000000

Again, double-click the file to import it into the Registry.

Folder Background Images in WinXP

Posted on October 16, 2006 in Technology by Jeff Starr

This brief tutorial explains how to add a background image to any folder in Windows XP.

First, make sure all hidden files are visible on your system. Then, open the folder for which you wish to add a background image. Within the folder, right-click and select Properties » Customize tab » Customize. There, choose any icon, click Apply and OK.

That process should have created a "desktop.ini" file. Open that file with a text editor and add these lines of code:

[ExtShellFolderViews]
{BE098140-A513-11D0-A3A4-00C04FD706EC}={BE098140-A513-11D0-A3A4-00C04FD706EC}
[{BE098140-A513-11D0-A3A4-00C04FD706EC}]
IconArea_Image=C:\path\folder\background.jpg

To customize this according to your needs, edit the path in the last line to reflect to the location of the image you wish to use as the background image for that folder. Refresh the folder and the new background should appear.

Finally, to remove the default icon chosen during the creation of the desktop.ini and restore the default folder icon, delete these lines of code from within the desktop.ini file:

[.ShellClassInfo]
IconFile=%SystemRoot%\system32\shell32.dll
IconIndex=(some number)

WordPress Core File Edits at Perishable Press

Posted on August 15, 2006 in Perishable, WordPress by Jeff Starr

Update: After upgrading Perishable Press in 2007, many of the hacks listed on this page are no longer applicable. Please refer to our new WordPress Core Edits for current information. Otherwise, this article remains online for reference purposes only.

The folks developing WordPress are continually rolling out “upgrades”. While it is generally a good idea to stay current, it can also be a bit of a pain if you have made any changes to the WordPress core files. Our recommendation? Keep a log such as this one that either includes all edits or links to posts describing them. That way, when it is time to upgrade to WP 3.0.1, WP 3.0.2, … WP 9.0.1, WP 9.0.2 … (you get the idea), it will simply be a matter of referring to your handy WP core file change log and then going thru the list, copying & pasting your way back to complete functionality. Just remember to add any subsequent changes to the list, though, or you may find yourself scratching your head after the next upgrade. Another good idea involves carefully comparing any code you are replacing, checking to make sure the wizards at WordPress haven’t changed any aspects of the original code (of which you are replacing).

So, without further ado, here are the WordPress core file edits currently operating here at Perishable Press:

Customize the_excerpt function

File: wp-includes/functions-formatting.php (~ lines #763 & 767): set to desired values:

$excerpt_length = 50;
...
array_pop($words);
array_push($words, '[...] ( click post title to read more )');
$text = implode(' ', $words);

Customize the wpautop function

File: wp-includes/functions-formatting.php (~ line #72, #83):

$pee = preg_replace('/\n?(.+?)(?:\n\s*\n|\z)/s', "<p>$1</p>\n\t\t\t\t\t\t", $pee); // make paragraphs, including one at the end
$pee = str_replace("<p><!--", "<!--", $pee);
$pee = str_replace("--></p>", "-->", $pee);
return $pee;

Customize the more quicktag

File: wp-includes/template-functions-post.php (~ lines #54, 62, 92):

function the_content($more_link_text = 'Continued >>', $stripteaser = 0, $more_file = '') {
   $content = get_the_content($more_link_text, $stripteaser, $more_file);
   $content = apply_filters('the_content', $content);
   $content = str_replace(']]>', ']]&gt;', $content);
   echo $content;
}
...
function get_the_content($more_link_text = 'Continued >>', $stripteaser = 0, $more_file = '') {
   global $id, $post, $more, $single, $withcomments, $page, $pages, $multipage, $numpages;
   global $preview;
   global $pagenow;
   $output = '';
...
...
else
   //$output .= ' <a href="'. get_permalink() . "#more-$id\">$more_link_text</a>";
   $output .= ' <a href="'. get_permalink() . "\">$more_link_text</a>";
}

Customize Default Password Text

File: wp-includes/comment-functions.php (~ line #296):

Password Required

WordPress RDF Source Makeover

File: wp-includes/comment-functions.php (~ line #513):

function trackback_rdf($timezone = 0) {
	global $id;
	if (!stristr($_SERVER['HTTP_USER_AGENT'], 'W3C_Validator')) {
	echo '<rdf:RDF ';
	echo "\n";
	echo '   xmlns:dc="http://purl.org/dc/elements/1.1/" ';
	echo "\n";
	echo '   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" ';
	echo "\n";
	echo '   xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">';
	echo "\n";
	echo '<rdf:Description ';
	echo "\n";
	echo '   dc:creator="';
	the_author();
	echo '" '."\n";
	echo '   dc:date="';
	the_date_xml();
	echo ' @ ';
	the_time('g:i a');
	echo '" '."\n";
	echo '   dc:title="'.str_replace('--', '&#x2d;&#x2d;', wptexturize(strip_tags(get_the_title()))).'" '."\n";
	echo '   rdf:about="';
	the_permalink();
	echo '" '."\n";
	echo '   dc:identifier="';
	the_permalink();
	echo '" '."\n";
	echo '   trackback:ping="'.trackback_url(0);
	echo '" '."\n";
	echo '   dc:description="';
	the_excerpt_rss();
	echo '" />'."\n";
	echo '</rdf:RDF>';
	}
}

And then replace the_excerpt_rss(); with:

the_content_rss('', TRUE, '', 7, 2);

Title Attributes for WordPress Post Navigation

File: wp-includes/template-functions-links.php (~ lines #348, 369, 459, 494, 503):

$string = '<a href="'.get_permalink($post->ID).'" title="Go to previous post">'.$previous;
...
$string = '<a href="'.get_permalink($post->ID).'" title="Go to next post">'.$next;
...
...
function next_posts_link($label='Next Page &raquo;', $max_page=0) {
...
echo '" title="Go backward in time">'. preg_replace('/&([^#])(?![a-z]{1,8};)/', '&#038;$1', $label) .'</a>';
...
function previous_posts_link($label='&laquo; Previous Page') {
...
echo '" title="Go forward in time">'. preg_replace('/&([^#])(?![a-z]{1,8};)/', '&#038;$1', $label) .'</a>';
...
function posts_nav_link($sep=' &#8212; ', $prelabel='&laquo; Previous Page', $nxtlabel='Next Page &raquo;') {

Vars Tweak for htaccess Edits

File: wp-includes/vars.php (~ #35):

// Server detection
//the next line is used to allow WP to write htaccess rules during permalink creation (comment out the $is_apache line first)
//$is_apache = 1;
$is_apache = ( strstr($_SERVER['SERVER_SOFTWARE'], 'Apache') || strstr($_SERVER['SERVER_SOFTWARE'], 'LiteSpeed') ) ? 1 : 0;

Customize Password-Protected Posts

File: template-functions-post.php (~ line #3):

function get_the_password_form() {
	$output = '<form action="' . get_settings('siteurl') . '/wp-pass.php" method="post">
	<p>' . __("This post is password protected. To view it please enter your password below:") . '</p>
	<p><small><label class="h">' . __("Password: ") . ' </label><input class="postpassword" name="post_password" type="password" size="11" /> <input class="passwordsubmit" type="submit" name="Submit" value="' . __("Submit &raquo;") . '" /></small></p>
	</form>
	<div class="clear vspace">&nbsp;</div>
	';
	return $output;
}

Reversing WordPress Post Navigation Order

File: template-functions-links.php (~ lines #503, 518):

Note: It looks like this change has been implemented (as of WP 2.0.5)..

function posts_nav_link($sep=' &#8212; ', $prelabel='&laquo; Previous Page', $nxtlabel='Next Page &raquo;') {
...
if ( $max_num_pages > 1 ) {
	previous_posts_link($prelabel);
	echo preg_replace('/&([^#])(?![a-z]{1,8};)/', '&#038;$1', $sep);
	next_posts_link($nxtlabel, $max_page);
}

Customize Quicktag Buttons

File: wp-includes/js/quicktags.js (~ line #37):

Required edit: delete the empty spaces out of the "pre code" button.

// CUSTOM QUICKTAGS BEGIN HERE

edButtons[edButtons.length] = new edButton('ed_authent'
,'authenticate'
,'<!--authenticate-->'
,''
,''
);

edButtons[edButtons.length] = new edButton('ed_quotes'
,'quotes'
,'&ldquo;'
,'&rdquo;'
,''
);

edButtons[edButtons.length] = new edButton('ed_dash'
,'dash'
,'&#8212;'
,''
,''
);

edButtons[edButtons.length] = new edButton('ed_rsquo'
,'rsquo'
,'&rsquo;'
,''
,''
);
edButtons[edButtons.length] = new edButton('ed_lsquo'
,'lsquo'
,'&lsquo;'
,''
,''
);

edButtons[edButtons.length] = new edButton('ed_acronym'
,'acronym'
,'<acronym title="">'
,'</acronym>'
,''
);

edButtons[edButtons.length] = new edButton('ed_clearspace'
,'clearspace'
,'<div class="clear vspace">&nbsp;</div>'
,''
,''
);
edButtons[edButtons.length] = new edButton('ed_follow'
,'follow link'
,'<a href="" title="">'
,'</a>'
,''
);
edButtons[edButtons.length] = new edButton('ed_nofollow'
,'nofollow link'
,'<a href="http://" title="" rel="nofollow">'
,'</a>'
,''
);
edButtons[edButtons.length] = new edButton('ed_press-link'
,'press link'
,'<a href="http://perishablepress.com/" title="Perishable Press">'
,'</a>'
,''
);
edButtons[edButtons.length] = new edButton('ed_reflist'
,'ref list'
,'<h3 class="references"></h3>\n\t<ul class="refs">\n\t<li><sup>1</sup> <a href="http://" title=""></a></li>\n\t<li><sup>2</sup> <a href="http://" title=""></a></li>\n'
,'</ul>'
,''
);
edButtons[edButtons.length] = new edButton('ed_content-link'
,'content-link'
,'<a href="http://perishablepress.com/press/wp-content/online/" title="Perishable Press">'
,'</a>'
,''
);
edButtons[edButtons.length] = new edButton('ed_press-image'
,'press image'
,'<img src="http://perishablepress.com/press/wp-content/images/" title="" alt="" />'
,''
,''
);
edButtons[edButtons.length] = new edButton('ed_pre-code'
,'pre code'
,'< pre>< code>'
,'< /code>< /pre>'
,''
);
edButtons[edButtons.length] = new edButton('ed_sup'
,'sup'
,'<sup>'
,'</sup>'
,''
);
edButtons[edButtons.length] = new edButton('ed_quot'
,'quot'
,'&quot;'
,''
,''
);
edButtons[edButtons.length] = new edButton('ed_<'
,'<'
,'&lt;'
,''
,''
);
edButtons[edButtons.length] = new edButton('ed_>'
,'>'
,'&gt;'
,''
,''
);

// CUSTOM QUICKTAGS END HERE

Remove the Admin Post-Preview Panel

File: wp-admin/post.php (line #83) & wp-admin/edit-form-advanced.php (line 17):

First, open wp-admin/post.php and delete these lines:

<div id='preview' class='wrap'>
<h2 id="preview-post"><?php _e('Post Preview (updated when post is saved)'); ?> <small class="quickjump"><a href="#write-post"><?php _e('edit &uarr;'); ?></a></small></h2>
<iframe src="<?php echo wp_specialchars(apply_filters('preview_post_link', add_query_arg('preview', 'true', get_permalink($post->ID)))); ?>" width="100%" height="600" ></iframe>
</div>

Then, open wp-admin/edit-form-advanced.php and delete these lines:

<?php if ( 0 != $post_ID ) : ?>
 <small class="quickjump"><a href="#preview-post"><?php _e('preview &darr;'); ?></a></small>
<?php endif; ?>

Enhance parse_url Functionality

File: wp-includes/functions.php (~ lines #1067): insert "@" before parse_url and praise the Lord!

Remove CSS Link to Print Stylesheet

File: press/wp-subscription-manager.php (~ line #100): delete the following line to eliminate unnecessary 404 errors when users subscribe/unsubscribe to comments (or when managing subscriptions):

<link rel="stylesheet" type="text/css" media="print" href="<?php echo get_settings('siteurl'); ?>/print.css" />

Customize Comment Feed Link

File: wp-includes/feed-functions.php (line #84): edit according to current default theme requirements:

echo "<a href='$url'>$link_text</a>";

--- changed to --->

echo "<a class=\"feed-icon\" href='$url' title=\"Subscribe to comments for this article\" rel=\"nofollow\">$link_text</a>";

Customize Commentator Links

File: wp-includes/comment-functions.php (~lines #358-368): swap the following:

/* original */
function get_comment_author_link() {
	global $comment;
	$url    = get_comment_author_url();
	$author = get_comment_author();

	if ( empty( $url ) || 'http://' == $url )
		$return = $author;
	else
		$return = "<a href='$url' rel='external nofollow'>$author</a>";
	return apply_filters('get_comment_author_link', $return);
}
// core file edit listed at perishablepress.com
// http://perishablepress.com/press/2006/08/15/wordpress-core-file-edits/
function get_comment_author_link() {
	global $comment;
	$url    = get_comment_author_url();
	$author = get_comment_author();

	if($comment->comment_type == 'pingback' || $comment->comment_type == 'trackback' ) { 
				if ( empty( $url ) || 'http://' == $url ) {
					$return = $author;
				} else {
					$return = '<a href="'.$url.'" rel="external">'.$author.'</a>';
				}
	} else {
				if ( empty( $url ) || 'http://' == $url ) {
					$return = $author;
				} elseif ( $author == 'blacklist' ) {
					$return = '<a href="'.$url.'" rel="external nofollow">'.$author.'</a>';
				} else {
					$return = '<a href="'.$url.'" rel="external">'.$author.'</a>';
				}
	}
	return apply_filters('get_comment_author_link', $return);
}

References

Customize Password-Protected Posts

Posted on May 22, 2006 in Function, WordPress by Jeff Starr

To customize WordPress-powered password-protected posts such as this one, follow these simple steps.

First open template-functions-post.php and find the function get_the_password_form, which is located near the top of the page.

There are several aspects of this function that you may wish to customize. For example, the Perishable Press website requires several CSS attributes for stylistic control. Thus we simply added the class postpassword to the form input field, as well as the class passwordsubmit to the form submit button. This enabled full stylistic control over password-protected posts. You may also wish to modify the size of the input text field, or even edit the submit-button text.

Finally, remember to check both the post comment view for proper “password message” display. If it is not, edit the local comments.php file (usually near the top) until the message displays correctly.

WordPress RDF Source Makeover

Posted on February 22, 2006 in Websites, WordPress by Jeff Starr

Beautiful Source-Code Output, Part 1: Whip your WordPress RDF Code into Submission

Update: This article applies specifically to WordPress 2.0.2, but may be generalized to any WP 2.0+ version.

I love looking at beautiful source-code output. However WordPress tends to spit code out in random chunks, often leaving spaces, line breaks, and tabs littered throughout the source output. This messes things up. Lists don’t look like lists and logically written code often appears scattered along the page carelessly. Often, this is the result of poorly written PHP, which can be manipulated to write beautifully aligned code that looks as good as it works.

For the first article in this series, we will bring order to the typical RDF chaos that WordPress spits out by default. To see an example of this, check out this source code, taken directly from the output of a default installation of WordPress. Notice how the awkward chunk of code leans, strangely enough, to the right. This type of RDF-code output seems to be the norm for WordPress users who have enabled that particular feature.

Okay, so it looks hideous, and we want to clean it up and make it shine. First thing to do is backup everything, even your database. Don’t trip though — this is a simple “cut-and-paste” procedure, but it is always a good idea to have a recent backup of your data just in case. Next, open the file wp-includes/comment-functions.php and find the function trackback_rdf, which is located about halfway down the page on line #525 (#509 for WP 2.0). Now, replace the following block of PHP code:

function trackback_rdf($timezone = 0) {
	global $id;
	if (!stristr($_SERVER['HTTP_USER_AGENT'], 'W3C_Validator')) {
	echo '<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" 
	    xmlns:dc="http://purl.org/dc/elements/1.1/"
	    xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
		<rdf:Description rdf:about="';
	the_permalink();
	echo '"'."\n";
	echo '    dc:identifier="';
	the_permalink();
	echo '"'."\n";
	echo '    dc:title="'.str_replace('--', '&#x2d;&#x2d;', wptexturize(strip_tags(get_the_title()))).'"'."\n";
	echo '    trackback:ping="'.trackback_url(0).'"'." />\n";
	echo '</rdf:RDF>';
	}
}

with our new and improved version1:

function trackback_rdf($timezone = 0) {
	global $id;
	if (!stristr($_SERVER['HTTP_USER_AGENT'], 'W3C_Validator')) {
	echo '<rdf:RDF ';
	echo "\n";
	echo '   xmlns:dc="http://purl.org/dc/elements/1.1/" ';
	echo "\n";
	echo '   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" ';
	echo "\n";
	echo '   xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">';
	echo "\n";
	echo '<rdf:Description ';
	echo "\n";
	echo '   dc:creator="';
	the_author();
	echo '" '."\n";
	echo '   dc:date="';
	the_date_xml();
	echo ' @ ';
	the_time('g:i a');
	echo '" '."\n";
	echo '   dc:title="'.str_replace('--', '&#x2d;&#x2d;', wptexturize(strip_tags(get_the_title()))).'" '."\n";
	echo '   rdf:about="';
	the_permalink();
	echo '" '."\n";
	echo '   dc:identifier="';
	the_permalink();
	echo '" '."\n";
	echo '   trackback:ping="'.trackback_url(0);
	echo '" '."\n";
	echo '   dc:description="';
	the_excerpt_rss();
	echo '" />'."\n";
	echo '</rdf:RDF>';
	}
}

Finally, open your WordPress theme’s “index.php” file, find the loop, and add an echoed line break to the commented-out RDF function. Your code should now look like this:

<!--
<?php trackback_rdf(); ?>
<?php echo "\n"; ?>
-->

That’s it — save the two files, upload them, refresh your pages, and check the RDF output in the source code. If all goes well, your RDF code should now resemble this:

<!--
<rdf:RDF 
   xmlns:dc="http://purl.org/dc/elements/1.1/" 
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" 
   xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
<rdf:Description 
   dc:creator="Perishable" 
   dc:date="2006-02-22 @ 11:19 am" 
   dc:title="WordPress RDF Source Makeover" 
   rdf:about="http://perishablepress.com/press/?p=49" 
   dc:identifier="http://perishablepress.com/press/?p=49" 
   trackback:ping="http://perishablepress.com/press/wp-trackback.php?p=49" 
   dc:description="Beautiful Source-Code Output, Part 1: Whip your WordPress RDF Code into Submission
I love looking at beautiful source-code output. [...continued &#187;]" />
</rdf:RDF>
-->

Now that’s much better!

Next time we will look at constructing righteous headings and pimping them for excellence on planet source-code output.

Update: To gain greater control over your WordPress RDF source-code output, replace the native function, the_excerpt_rss(); (located near the last line of the trackback_rdf() function), with the more flexible function, the_content_rss. This function provides five parameters as described in the WordPress Codex:

<?php the_content_rss('more_link_text', strip_teaser, 'more_file', cut, encode_html); ?>

More specifically, here is how we use the function to limit the number of words output in the dc:description attribute, thus optimizing bandwidth while preventing unruly code examples from disrupting document structure (as in the case of JavaScript comments):

the_content_rss('', TRUE, '', 7, 2);

Fin

References

WordPress Notes Plus

Posted on February 12, 2006 in Websites, WordPress by Jeff Starr

Welcome to Perishable Press! This article covers many different aspects of WordPress functionality, including customizing quicktags, deleting the cache, numbering comments & posts, changing password text, and displaying archive menus. Note that this article was written for previous versions (i.e., less than 2.0) of WordPress. Discrepancies may exist between the code presented in this post and that of more recent versions of WordPress. Nonetheless, this information is presented for references purposes with the hope that it will prove useful for those working with everyone’s favorite blogging platform, WordPress!

Customize WordPress Quicktags

The more Quicktag:

The <!--more--> Quicktag breaks a post into “teaser” and content sections. Type a few paragraphs, insert this tag, then compose the rest of your post. On your blog’s home page you’ll see only those first paragraphs with a “(more…)” hyperlink, which when followed displays the rest of the post’s content.1

Customize the more Quicktag:

To customize the “(more…)” hyperlink, open the file “wp-includes/template-functions-post.php” and locate the following lines (around lines #54 & #62, respectively):

function the_content($more_link_text = '(more...)', $str...
function get_the_content($more_link_text = '(more...)', $str...

For each line, carefully replace (more...) with whatever text you wish. Possibilities include Continued >> and [ Read on... ].

Modify the Target of the more Quicktag:

To modify the target of the “(more…)” hyperlink, replace the following statement (located within “wp-includes/template-functions-post.php” around line #92):

$output .= ' <a href="'. get_permalink() . "#more-$id\">$more_link_text</a>";

with:

$output .= ' <a href="'. get_permalink() . "\">$more_link_text</a>";

The nextpage Quicktag:

The <!--nextpage--> Quicktag is similar to the more tag, except it can be used any number of times in a post, and each insert will “break” and paginate the post at that location. Hyperlinks to the paginated sections of the post are then generated in combination with the wp_link_pages() or link_pages() template tag.2

Customize the_excerpt Function

Open the file “wp-includes/functions-formatting.php” and find the following line of code (located around line #732):

array_push($words, '[...]');

To customize the continuation notation for excerpts, simply replace [...] with the text of your choice. Something like “[...continued &raquo;]” or “[ click post title to read more ]” works just swell.

To change the default number of words included in excerpts, edit the 55 in the following line of code (located around line #728) to reflect the desired number of excerpt words:

$excerpt_length = 55;

Fix the WordPress "Remember Me" Option

If the WordPress admin seems to “forget” you even after following all of the proper protocols, try changing the actual link that takes you to your WP admin-login page. Change the link from /wp-login.php (the file) to /wp-admin/ (the directory).

Cache Notes

It is totally safe to delete everything in the /wp-content/cache/ folder!

Custom Number of Posts

Sometimes it is nice to customize the number of posts displayed for different loops. For example, if you have different themes, it is possible for one theme to show five posts while another theme only shows one post. To pull it off, simply place the following line of PHP before the loop:

<?php query_posts('showposts=n'); ?>

Where "n" represents the number of posts that the loop will display 3. Nice ;) Update: This method needs some work — seemed okay at first, but then links to posts always go to the first blog page..

Tweaking Comment Numbers

Instruct WordPress to begin each post’s comment numbers with the number "1" (or any number), and then proceed numerically thenceforth by adding this line at the top of comments.php..

<?php $commentcount=1; // number of first comment for each post ?>

..and then placing this line at the location where you would like the comment numbers to appear:

<?php echo $commentcount++; ?>

Another method for accomplishing the same thing involves replacing this code (located in comments.php)..

<?php if ( $comments ) : ?>
<?php foreach ($comments as $comment) : ?>

..with this..

<?php if ( $comments ) : ?>
<?php foreach ($comments as $comment) : $comment_count++;?>

..and then placing this line at the location where you would like the comment numbers to appear:

<?php echo $commentcount++; ?>

Customize Default Password Text

To change the default WordPress password text, open the file "wp-includes/comment-functions.php", and scroll to around line #309. Look for the password text and change it to whatever you prefer. Note: this default password text is different than the password text specified in the comments.php file.

Dropdown Archive Menus

To create dropdown archive menus (using get_archives4), simply emulate one of the following chunks of code and tweak to suit:


<select name="archivemenu" onChange="document.location.href=this.options[this.selectedIndex].value;">
<option value="">Daily Archives</option>
<?php get_archives('daily','33','option','','','FALSE'); ?>
</select>

<select name="archivemenu" onChange="document.location.href=this.options[this.selectedIndex].value;">
<option value="">Daily Archives</option>
<?php get_archives('postbypost','33','option','','','FALSE'); ?>
</select>

<select name="archivemenu" onChange="document.location.href=this.options[this.selectedIndex].value;">
<option value="">Monthly Archives</option>
<?php get_archives('monthly','12','option','','','TRUE'); ?>
</select>

<select name="archivemenu" onChange="document.location.href=this.options[this.selectedIndex].value;">
<option value="">Daily Archives</option>
<?php get_archives('daily','7','option','','','FALSE'); ?>
<option value="">Monthly Archives</option>
<?php get_archives('monthly','7','option','','','TRUE'); ?>
<option value="">Yearly Archives</option>
<?php get_archives('weekly','7','option','','','TRUE'); ?>
</select>

References