Fall Sale! Code FALL2024 takes 25% OFF our Pro Plugins & Books »
Web Dev + WordPress + Security

WordPress Notes Plus

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 »]” 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_archives), 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>

Footnotes

About the Author
Jeff Starr = Web Developer. Book Author. Secretly Important.
BBQ Pro: The fastest firewall to protect your WordPress.

4 responses to “WordPress Notes Plus”

  1. Militantplatypus 2006/09/20 9:02 am

    I am attempting to modify the text for the more tag, but I can’t seem to get it to change. I have found the two functions you mention, and the list the text ‘more..’, but that is not what is displayed when I use the tag.

    Here are the functions copied out of my theme:

    function the_content($more_link_text = '(more...)', $stripteaser = 0, $more_file = '') {
    	$content = get_the_content($more_link_text, $stripteaser, $more_file);
    	$content = apply_filters('the_content', $content);
    	$content = str_replace(']]>', ']]>', $content);
    	echo $content;
    }
    
    function get_the_content($more_link_text = '(more...)', $stripteaser = 0, $more_file = '') {
    	global $id, $post, $more, $single, $withcomments, $page, $pages, $multipage, $numpages;
    	global $preview;
    	global $pagenow;
    	$output = '';
    	...
    }

    And here is the text that is being displayed:

    Read the rest of this entry »

    Any help you could offer would be greatly appreciated.

  2. Militantplatypus,

    The method of changing the "More.." tag described in this article changes the default More tag text, which affects the blog universally. This is useful if you have many themes or do not feel like adding extra code to your pages.

    On the other hand, WordPress also provides a localized method of changing the More tag text. Simply open your theme’s index.php file and locate the following PHP call:

    <? php the_content(); ?>

    Add your preferred More tag text within the parentheses as follows:

    <? php the_content('Custom More text...'); ?>

    Custom More tag text indicated locally will override the specified default text.

  3. inspirationbit 2007/01/29 1:32 pm

    I’m using More quick tags for my blog, and after updating to new WordPress 2.1 it stopped showing full feed RSS. RSS shows my content until the More tag as well. How can I change it back so my RSS shows full feeds?
    Thank you.

  4. inspirationbit,

    We have yet to upgrade to WP 2.1, so it is difficult to imagine the possible cause of your dilemma. However, we will try to investigate this issue once we are running 2.1.

Comments are closed for this post. Something to add? Let me know.
Welcome
Perishable Press is operated by Jeff Starr, a professional web developer and book author with two decades of experience. Here you will find posts about web development, WordPress, security, and more »
Wizard’s SQL for WordPress: Over 300+ recipes! Check the Demo »
Thoughts
Went out walking today and soaked up some sunshine. It felt good.
I have an original box/packaging for 2010 iMac if anyone wants it free let me know.
Always ask AI to cite its sources.
All free plugins updated and ready for WP 6.6 dropping next week. Pro plugin updates in the works also complete :)
99% of video thumbnail/previews are pure cringe. Goofy faces = Clickbait.
RIP ICQ
Crazy that we’re almost halfway thru 2024.
Newsletter
Get news, updates, deals & tips via email.
Email kept private. Easy unsubscribe anytime.