Favorite Codex Tip Of The Day

To remove meta boxes created by plugins, 'admin_menu' is fired too early, use 'do_meta_boxes' instead.

Such a simple thing, but I wasted at least 15 minutes by using the wrong action hook. The meta box in this case was not created by a plugin, but by the parent theme of a child theme that I am building.

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.

Don’t get_the_permalink()

get_the_permalink() does not exist. Use get_permalink().

Note to self: Debug my own site like I would debug any other site.

I have used that function an uncountable amount of times, but got confused anyway because of having get_the_title() on my brain.

This tip was brought to you by the half hour of my life that I will never get back.

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

INSIDE THE LOOP:

OUTSIDE THE LOOP:

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.

CSS:

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

Function: wp_tag_cloud

Usage:

Defaults:

Parameters:

smallest
(integer) (optional) The text size of the tag with the smallest count value (units given by unit parameter).

Default: 8

largest
(integer) (optional) The text size of the tag with the highest count value (units given by the unit parameter).

Default: 22

unit
(string) (optional) Unit of measure as pertains to the smallest and largest values. This can be any CSS length value, e.g. pt, px, em, %.

Default: ‘pt’

number
(integer) (optional) The number of actual tags to display in the cloud. (Use ‘0’ to display all tags.)

Default: 45

format
(string) (optional) Format of the cloud display.

  • ‘flat’ separated by whitespace defined by ‘separator’ parameter.
  • ‘list’ UL with a class of ‘wp-tag-cloud’
  • ‘array’ returns the tag cloud as an array for use in PHP

Default: flat

separator
(string) (optional) The text/space between tags.

Default: ‘\n’ (whitespace)

orderby
(string) (optional) Order of the tags.

  • ‘name’
  • ‘count’

Default: name

order
(string) (optional) Sort order.

  • ‘ASC’
  • ‘DESC’
  • ‘RAND’ tags are in a random order.

Default: ASC

exclude
(string) (null) optional

Default: None

include
(string) (null) optional

Default: None

topic_count_text_callback
(string) (optional) The function, which, given the count of the posts with that tag, returns a text for the tooltip of the tag link.

Default: default_topic_count_text

link
(string) (optional) Set link to allow edit of a particular tag.

  • ‘view’
  • ‘edit’

Default: view

taxonomy
(string or array) (optional) Taxonomy or array of taxonomies to use in generating the cloud.

  • ‘post_tag’
  • ‘category’
  • ‘link_category’
  • ‘any other registered taxonomy’
  • or array of taxonomies Note: this parameter was introduced with Version 3.1

Default: post_tag

echo
(boolean) (optional) Display the result or return it in a variable. The default is true (display the tag cloud).

  • 1 (true)
  • 0 (false)

Default: true

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 Page Template

Genesis: Default Post Thumbnail

Genesis Grid Loop

New in Genesis 1.5

CSS:

PHP:

Change Login Page Logo

CSS Column Classes and Shortcodes

CSS:

Example HTML:

Shortcode Example:

[one-half-first]Nulla facilisi. Duis aliquet egestas purus in blandit. Curabitur vulputate, ligula lacinia scelerisque tempor, lacus lacus ornare ante, ac egestas est urna sit amet arcu. Class aptent taciti sociosqu ad.[/one-half-first]

[one-half]Nulla facilisi. Duis aliquet egestas purus in blandit. Curabitur vulputate, ligula lacinia scelerisque tempor, lacus lacus ornare ante, ac egestas est urna sit amet arcu. Class aptent taciti sociosqu ad.[/one-half]

Output:

Nulla facilisi. Duis aliquet egestas purus in blandit. Curabitur vulputate, ligula lacinia scelerisque tempor, lacus lacus ornare ante, ac egestas est urna sit amet arcu. Class aptent taciti sociosqu ad.

Nulla facilisi. Duis aliquet egestas purus in blandit. Curabitur vulputate, ligula lacinia scelerisque tempor, lacus lacus ornare ante, ac egestas est urna sit amet arcu. Class aptent taciti sociosqu ad.

Genesis: Custom search button and search form text

Genesis Footer Content

Customize the footer text

Remove Footer Content

This will remove the footer credits text and ‘back to top’ link.

Replace Footer With A WordPress Custom Menu

This will replace the default footer with credit text and a WordPress custom navigation menu.
Ex. © Copyright 2011 LBnuke. All rights reserved.    Home | About | Archives | Contact

Genesis: Custom superfish arguments

Genesis: Parent Page Templates

The template below displays child posts below any page content of the parent post with featured image thumbnails. Images are linked to child page. If there is an image before any page content on the child page, it will not display in order to avoid breaking the layout on posts with large images.

To display the images on the right side, change the class on this line (~ line 17):

from

to

Parent Page Template:

functions.php:

Changelog
2/23/2011: Added links to featured images and ob_end_clean() to word count function.

genesis();

This is what happens when you call the genesis() function:

Define Genesis default options

Available Options:

Remove Genesis Distractions

Remove Genesis options page

Remove in-post layout and SEO boxes

Unregister Site Layouts

Genesis: Disable SEO Functions