Rambling On…

Change Admin Post/Page List Color By Status — 09/09/2011

Change Admin Post/Page List Color By Status

Favorite WordPress tip of the week:

This snippet will change the background colors of posts, pages, and custom post types in the administration post/page lists based on their status, i.e. draft, private, pending, etc.

Note: Draft color changed to a slightly lighter yellow than original.
Update on 5/18/2016: Changed pending color to lighter blue.

Get the Current Page URL — 07/08/2011

Get the Current Page URL

I am working on a site now where I need to use the current page URL as a condition to determine where the main menu links will lead. This function has made an easy task of it:

Komodo Snippet for Comment Banners — 07/05/2011

Komodo Snippet for Comment Banners

I like to keep my code organized and easy to read, but since I am almost always working on a tight deadline, I do not always have time to organize and comment my code as well as I would like to. Shortcuts that aid in keeping my code organized are more likely to get used than their longer counterparts. Comment banners are one way to keep code organized, especially in large files.

In Komodo, the following snippets will turn highlighted text into a comment banner, or if no text is selected, pop up a dialog box asking for the Banner Title. After inserting the banner, the cursor will be be positioned below it. These snippets will work for any code editor, IDE, etc. if you leave out the [[%(s:orask:Banner Title)]] or replace it with whatever works for your software.

You can set a key binding for this shortcut in the ‘Key Binding’ tab of the snippet properties dialog window.

To create a new snippet in Komodo Edit or IDE, open up the Toolbox pane (View > Tabs & Sidebars > Toolbox), and either click on the gear icon and choose ‘New Snippet’, or right-click on a folder where you want to store the snippet and choose ‘New Snippet’.

The snippet dialog box will appear. Give the snippet a title, and place the following text into the larger text box:

PHP, C, C++, C#, Java, JavaScript, ActionScript, etc.:

PHP, JavaScript, CSS, ActionScript, C, C++, C#, Java, etc.:

Small Banner:


The important part is the interpolation shortcut ([[%(s:orask:Banner Title)]]). You can make the banner look however you like as long as the text is wrapped in code that denotes a comment. Make sure to position the cursor a line or two below the banner.

Check the box for ‘Maintain selected text or cursor position after insertion’. The second check box is optional, but recommended. When you are finished, the box should look something like this:

Komodo PHP Comment Banner Snippet
Komodo PHP Comment Banner Snippet

Click ‘OK’ to save the snippet.

To use the snippet, highlight or enter the banner text and double-click on the snippet in your Tools pane or type your keyboard shortcut. Your banner will be inserted and the cursor will be positioned and ready for the next line of code.

Customize the WordPress Login Page —

Customize the WordPress Login Page

Custom Login Page
Custom Login Page

I love WordPress and am personally very happy to see the WordPress logo when I log into a site, but when building sites for some clients (and on my own development site where I build sites for clients to preview), it is nice to use their own logo for the login page. It gives a more professional look and fits in with the rest of their branding.

This snippet will use a custom logo instead of the WordPress default logo.

1. Upload your logo to the server, either manually or through the WordPress media library. It is best if the logo image is 326px x 82px or smaller.

2. In your theme’s functions.php file, add this code:

Replace PATH_TO_IMAGE/YOUR_IMAGE.png with the path to your logo image, i.e. images/logo.png.

To customize the entire login page (including the logo), you can use a similar function to call a custom stylesheet for the login page:

Display Custom Fields In & Out of The Loop — 05/25/2011

Display Custom Fields In & Out of The Loop



Numbered Search Results in WordPress — 03/04/2011

Numbered Search Results in WordPress

I needed to show search results in an ordered list for a project I am working on and was very surprised to discover how involved this is for paginated search results. Showing the results using a regular ordered list starts the list numbering over at 1 on each new page of results, even though the next set of results was being displayed.

After some horribly hacky solution involving grabbing the page number from the URL and hard coding the number of posts per page, I was led in the right direction by NicktheGeek at StudioPress who suggested getting the number of posts per page from the query string and using the paged value to get the numbers dynamically before applying the math to get the list numbers to display correctly.

A bunch of CSS was required to make the list numbers look like they were actually generated by an <ol> tag. Styling will vary depending on your theme, but one thing that may help if things are looking messed up is to display the post/page titles and contents inline.


For non-Genesis themes, leave out the genesis_ lines.

Genesis: Remove/Change post info/post meta — 02/18/2011

Genesis: Remove/Change post info/post meta

Please note that you do not need to remove the functions before editing them. Hat tip to jim 🙂

Genesis: Custom loop arguments —

Genesis: Custom loop arguments

Genesis: Custom Page Template —

Genesis: Custom Page Template

Genesis: Default Post Thumbnail —

Genesis: Default Post Thumbnail