Remove Emoji Support from WordPress 4.2

May 19, 2015 (9 years ago)
Functions, JS, WordPress

4.2 added the ability to use Emojicons in WP posts. If you don’t use them, you can remove the (unnecessary) scripts this adds to the header on all your site pages. Here’s the code for your functions.php file:

 Thank you, Paulund!

http://www.paulund.co.uk/disable-emojicons-introduced-in-wordpress-4-2

The Current Template Name

March 3, 2015 (9 years ago)
WordPress

This will output the name of the template being called on any particular page or post or archive.

 

Include page content in another page

March 3, 2015 (9 years ago)
WordPress

Here’s a quick and easy way to include content from one page into another:

 

Embedding a Video in a Template File

January 11, 2015 (9 years ago)
PHP, WordPress

Adding shortcodes to template files is a bit tricky. Although [ embed]myvideourl[ /embed] looks like a regular WP shortcode, it’s not handled the same way.

It works just as expected in a content block, but not so in a template file. Here’s the code to embed into the template:

 NOTE: To use this code, you will need to remove the spaces inside the brackets before ’embed’ and ‘/embed’.

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:

 

« Previous - Next »