Allow Multiple User Emails

December 23, 2014 (9 years ago)
Functions, WordPress

Ever need to allow your users to have non-unique email addresses? (i.e. two user accounts with the same email address)

Here’s the function:

 

Manage Dashboard Columns

December 18, 2014 (9 years ago)
Functions, WordPress

In the latest versions of WordPress, the number of columns showing in the dashboard are automatically generated based on your screen size. That works for many situations, but you may want to control the number of columns.

For example, if  you only have 1 or 2 items showing on your dashboard, it looks awkward on a large screen. So, here is a function that allows you to control the default and max number of columns:

 

Allow HTML in Excerpts

December 9, 2014 (9 years ago)
Functions, PHP, WordPress

By default, WordPress strips all HTML tags from excerpts. To allow them, simply replace the filter that creates the excerpt from your content.

First, copy the default excerpt filter from wp-includes/formatting.php:

 By changing the strip_tags parameters, you can allow whatever tags you want:

Also be sure to change the name of the function. Copy this to your functions.php file.

 Then, replace the default filter with your new one in functions.php:

 

wp_is_mobile

November 4, 2014 (9 years ago)
Questions, WordPress

Curious as to what you have/would use this function for?

Since it only detects browser agent and disregards size, what would you show/hide only for mobile viewers?

http://codex.wordpress.org/Function_Reference/wp_is_mobile

Replace “Howdy” in Admin Bar

October 20, 2014 (9 years ago)
Functions, WordPress

Use this function to replace “Howdy, $username” with “Welcome, $username”:

 Thanks to Thoriq Firdaus! Replayed from: http://www.hongkiat.com/blog/wordpress-howdy-customized/, where you’ll also find a clever function to customize the message for special occasions.

Don’t Delete Custom Fields on Quick Edit Save

October 20, 2014 (9 years ago)
Plugins, WordPress

When saving custom fields from a custom metabox, if the value is empty, usually the custom field is deleted. This is good, as it keeps from having lots of empty entries in the database.

However, it means that when you update from the “Quick Edit” menu, since your custom fields are not in the form, they will disappear. Not so good.

Here’s the fix.  Add this to your save function for the metabox:

 So, your save function should look something like this:

 

Database Maintenance

October 17, 2014 (9 years ago)
Database, WordPress

WordPress automatically deletes items you have trashed (posts, pages, etc) after 30 days. You can set this to fewer days to keep them from building up.

Put this in your wp-config.php file:

 

Limiting Revisions

October 17, 2014 (9 years ago)
Database, WordPress

To keep your database from bloating with endless revisions, you can limit the number that’s stored for each post.

Put this in your config.php file. (The second parameter is the number of revisions to keep.)

 

Limit Excerpt Text

October 17, 2014 (9 years ago)
Uncategorized

When you have layout areas with specific sizes, you need to limit the amount of text that appears. Rather than modify the excerpt size for the whole site, you can use this function:

 Then, call it in your template (from inside the loop) like this:

 

Load Child and Parent Style CSS

October 15, 2014 (9 years ago)
CSS, WordPress

If you are creating a child theme, you have two choices that load faster than using @import in your child style.css file.

1. You can add the parent style link to the child header.php, just above your normal css link.

 

2. You can add this to your functions.php file.

 

 

« Previous - Next »