Tag: upgrade

WordPress Plugin Central

Posted on May 29, 2006 in WordPress by Jeff Starr

Welcome to WordPress Plugin Central! Here we will organize, review, and log any changes made to the plugins used here at Perishable Press. Our first task involves listing all of the plugins used as of May 29, 2006 (Note: This list is updated with every plugin modification and is current as of the “Edited on” date in the “Post Metadata” section to the left of this post):

Continue Reading

Create New Permalink Category

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

If you are running WordPress 2.0.2 and have enabled permalinks, you may have had problems creating a new category or page to your site. I recently encountered this dilemma and devised the following strategy for adding, editing, or even deleting WordPress categories and pages. Note: this tutorial assumes you are running Apache.

First, open wp-includes/vars.php and find (around line #39):

$is_apache = ( strstr($_SERVER['SERVER_SOFTWARE'], 'Apache') || strstr($_SERVER['SERVER_SOFTWARE'], 'LiteSpeed') ) ? 1 : 0;

Comment out that line and add the following:

$is_apache = 1;

Save the file and upload it to your server.

Next, check the file attributes of your htaccess file(s). Ensure that the file is writable with a setting of either 666 or even 777 (or whatever works best on your server).

Finally, create or edit the necessary category or categories, publish a post or two under the new/edited category, and then double-check that everything is working as expected.

Now that you are a big winner with your new category, be sure to change the htaccess file permissions back to 644 or equivalent. Also, comment out the new line in the vars.php file and uncomment out (i.e., comment in) the original line of code.

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.

Perishable Press Server Migration

Posted on May 11, 2006 in Business, Perishable by Jeff Starr

As you may have read, we recently transferred our websites to a new server. Although the overall process went smoothly enough, several learning opportunities unfolded during the transfer of our humble Perishable Press website…

First, the setup. Perishable Press is a WordPress-powered website. On our previous server, we were running a Fantastico-installed WordPress version 2.0.2, upgraded from version 2.0. Permalinks were enabled and everything was running smoothly. Our database was only 13MB in size and around 12MB of that was disposable statistics information from WP-ShortStat and Bad Behavior. The crucial part of our database was a friendly 1MB in size.

Continue Reading

Title Attributes for WordPress Post Navigation

Posted on April 23, 2006 in Accessibility, WordPress by Jeff Starr

Improve accessibility by adding title attributes to your WordPress userspace.

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

By default, WordPress navigation links omit the title attributes for both page and post views. Title attributes for links provide additional information that can improve the accessibility of your website. This is especially true when images or text symbols exclusively are used for navigation.

To add title attributes to WordPress page-view links (e.g., links for index, archive, and category views), open the file wp-includes/template-functions-links.php and find the functions previous_posts_link (line #494) and next_posts_link (line #459).

Within each function, replace the following line:

echo '">'. preg_replace('/&([^#])(?![a-z]{1,8};)/', '&#038;$1', $label) .'</a>';

..with this:

echo '" title="EDIT THIS">'. preg_replace('/&([^#])(?![a-z]{1,8};)/', '&#038;$1', $label) .'</a>';

Next, replace the EDIT THIS text in each function with “Previous Posts” and “Next Posts”. Keep in mind the reverse chronological order by which these links navigate. Remember to check a few page views and then you are done.

Now, to add the title attribute to navigation links within individual post views. Open the same file as above, wp-includes/template-functions-links.php and find the functions previous_post (line #336) and next_post (line #357).

Within each function, replace the following line:

$string = '<a href="'.get_permalink($post->ID).'">'.$next;

..with this:

$string = '<a href="'.get_permalink($post->ID).'" title="EDIT THIS">'.$next;

Next, replace the EDIT THIS text in each function with “Previous Post” and “Next Post” respectively. Remember to check a few post views and then you are done.

Permalink Enlightenment

Posted on April 10, 2006 in Websites, WordPress by Jeff Starr

I recently enabled the permalinks feature for a fresh WordPress 2.0.2 upgrade. The process required several hours of research and approximately 90 minutes to fully implement. This brief article summarizes the process and applies to at least the following setup:

  1. WordPress 2.0.2
  2. Apache Server with mod_rewrite enabled
  3. The ability to access/modify your .htaccess file(s)
  4. You have decided to use the /%year%/%monthnum%/%day%/%postname%/ permalink format (actually, any format will work; simply swap your preferred format for the one mentioned here)
  5. You may also be using any of the plugins listed in the dungeon (actually, most plugins are compatible — only a few cause problems)

Permalinks are important for several reasons: search engines love them, people can understand them, and links (theoretically) become permanent because of them. Plus, all of the cool kids are using them, so you should too. They really add the finishing touches to your site and provide a sense of unity and sophistication that the “http://ugly-domain.com/blog/index.php?page_id=66” format just can’t match.

Before you begin any changes it is highly recommended to backup everything: WordPress files, database(s), notes, edited files, image files, htaccess file(s), etcetera. Just a friendly reminder.

Then, if you are seriously considering jumping into permalinks, do some research. Search Google, Ask, WordPress, and dig through a few blogs for terms such as “WordPress permalinks”, “permalink tips”, “permalink guide”, etc. As you learn, copy and paste any important notes, code, or links that seem important and may be useful later on. You may also wish to anticipate certain scenarios by searching for “permalink nightmare” or “permalink success”, for example.

Now that you have studied the process, you realize that certain conditions produce errors or other problems. For example, if you are planning on using the %postname% in your permalinks, very long post titles may cause problems in emails, posts, and chats. Although such an issue may be fixed after the fact, it is wise to scan through your posts and edit the post slug of any posts with excessively long titles. Regardless of the post title name, it is the post slug that is used when implementing the %postname% in permalinks. If possible, I recommend manually checking every post title and slug and editing (if needed) with permalinks %postname% in mind. Don’t forget to check your pages as well.

Now for the fun stuff. Well, almost. WordPress 2.0.2 has a problem writing to .htaccess files even when their CHMOD is set to 666 or 777. To fix this, open wp-includes/vars.php and replace the following line of code:

$is_apache = ( strstr($_SERVER['SERVER_SOFTWARE'], 'Apache') || strstr($_SERVER['SERVER_SOFTWARE'], 'LiteSpeed') ) ? 1 : 0;

..with this one:

$is_apache = 1;

This is a change that should be needed only during the establishment of permalinks. After you have permalinks flying high, you should revert the previous replacement and restore order to the galaxy.

Now create your htaccess file(s). Open a text editor and save a blank document as “htaccess” in the root of your site. Then rename it to “.htaccess” (i.e., put a dot before the name). Upload this file and change its CHMOD setting to 666. Again, this change should only endure until permalinks are functioning. So remember to change it back to its default setting (typically 644).

Okay, get ready to party. First restart your computer (for good measure). Then, open your WordPress Admin and navigate to the Permalinks submenu (under Options). Read everything carefully and then select the “Date and name based” option under the “Common options” menu. Make sure that WordPress automatically added /%year%/%monthnum%/%day%/%postname%/ (or that of your preferred format) to the “Custom structure” field. Now click the “Update Permalink Structure” button and wait for the “success” message to appear. At this point, permalinks should work throughout your WordPress-powered website.

Almost done. Check everything. First download your htaccess file and check that WordPress automatically added the htaccess directives required to create permalinks:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /press/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /press/index.php [L]
</IfModule>
# END WordPress

If you don’t see it, then copy and paste it into your htaccess file manually. If your htaccess file is blank, permalinks will not work. Once your htaccess file is good to go, clear your browser cache and surf your entire site — pages, posts — everything. Check internal links and external links. If possible, check links pointing to your site from elsewhere online. Every page or post should now be addressed by its corresponding and unique permalink, as displayed in your browser’s address field. If all is looking smooth, great. Remember to check the functionality of everything: commenting, posting, tagging, and editing posts. Also check your calendar, archives, search function, different themes, and plugin features (if any).

One problem I encountered (besides those inherently addressed in this article) involved an unwanted index.php statement included before the date in all permalinks. To fix this, you must access the wp_options table in your WordPress database. Once there, find the index field called option_name and search for the record rewrite_rules and clear the contents of the option_value. This will force WordPress to generate new permalink values based on current user settings. Read more via this thread at the WordPress Support Forums.

Don’t forget to reverse any changes made during the permalink conversion process.

References & Resources

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

Stupid htaccess Tricks

Posted on January 10, 2006 in Websites by Jeff Starr

Welcome to Perishable Press! This article, Stupid htaccess Tricks, covers just about every htaccess “trick” in the book, and is easily the site’s most popular offering. In addition to this htaccess article, you may also want to explore the rapidly expanding htaccess tag archive. Along with all things htaccess, Perishable Press also focuses on (X)HTML, CSS, PHP, JavaScript, security, and just about every other aspect of web design, blogging, and online success. If these topics are of interest to you, I encourage you to subscribe to Perishable Press for a periodic dose of online enlightenment ;)

Table of Contents

Continue Reading