Add a custom field to every public post types in WordPress with Advanced Custom Fields

Add a custom field to every public post type in WordPress by pasting this to your functions.php. Make sure you have Advanced Custom Fields Pro installed and activated. The custom fields will appear as a Option Page in WordPress admin.

 

Print the custom field on the archive page by adding this to the template file.

 

Custom logo in WooCommerce Storefront

Add this to your functions.php in your theme or plugin to add a custom logo in WooCommerce Storefront. Make sure to change the image source to what ever you want.

 

Featured image URL from Post ID in WordPress

Get featured image url from post id in WordPress, for when you’re to lazy to google it. This includes a custom image size as well.

 

Execute code on create, edit or delete taxonomy terms in WordPress

 

Sort tags and categories with ACF in WordPress

Start by adding a custom field to your tag or category with Advanced Custom Fields, name it to “custom_field” or something, and add this to your functions.php.

 

Modify the tag or category object in the loop by getting the custom field, but it back, sort it and use it how you want.

 

Get current post ancestors in WordPress

Get current post ancestors and list it’s children in WordPress.

 

Backup your WordPress database during development with GIT

Save daily backups of your WordPress database to file during development, to store them in GIT alongside with other developers databases.

First, define the environment by adding this to your wp-config.php:

Second, paste this to your functions.php:

 

Replace non-english characters (i.e. å,ä and ö) on file upload in WordPress

Replace non-english and weird characters in file name on upload in WordPress by adding this to your functions.php.

Updated. Credits goes to http://annalinneajohansson.com/2013/10/10/rensa-specialtecken-ur-filnamn-vid-uppladdning-i-wordpress/.

Modify ACF post object result to include Polylang language in WordPress admin

Modify the result in a ACF post object field in WordPress admin by including language slug from Polylang. Instead of having multiple object with the same title (but on different languages), add this to your functions.php. Don’t forget to change “field_name” to what ever your field is called.

 

Remove menu items for non-administrators in WordPress admin

Remove menu items for non-administrators in WordPress admin by adding this to your functions.php.