Get a human-readable debug backtrace including the the file, the function which calls it, and its line number. Usage: The following will print it directly to your WordPress error log (/wp-content/debug.log).
Archive for “WordPress Functions”
Quick snippets of Wordpress functions to paste in the functions.php file of your theme.
This lets you upload images from a theme or plugin right into the WordPress Media Library. This leaves the images unattached to any post. They will simply be sitting in the Media Library ready for use. If you want to attach the image to a post, or to set it as the featured image, see […]
This function will let you upload an image to a specific post and assign it as the featured image/post thumbnail. You can do this in a plugin or theme, using images that are contained within your package. If you want to upload images from your theme or plugin without attaching them to any post, see […]
This gives your WordPress image captions equal heights on a gallery page. The text captions will take the height of the tallest caption on the page. This applies to the “gallery-caption” element, not to the entire “gallery-item” element. This is useful if you added a background color for your “gallery-caption” or “wp-caption-text“. Captions with a […]
This function will add a sub-menu item to an existing menu item in wp_nav_menu, only if a user is logged in. Replace ‘main-menu’ on line 8 with the Theme Location of the menu that you want to modify. Use the slug of the location name. Find the Theme Location name in “Appearance -> Menus -> […]
This is useful for a case in which you have created a WordPress custom taxonomy, and then you’ve added a custom meta field to it. And then you want to assign a default value to the custom meta field for all the custom taxonomy terms. This will update all the custom taxonomy terms with a […]
This function will remove the “Customize” link from the WordPress Tool Bar, a.k.a the admin bar.
This wraps the comment author link with itemprop=”creator” microdata. It will be wrapped correctly with itemprop=”creator”, and itemscope itemtype=’http://schema.org/Person, then itemprop=’name’. This goes in your functions.php. This will apply to the comment author on each comment in your WordPress blog.
This function will remove the “?ver” from the URLs of of your static resources on your WordPress site. For example, it will remove the “version” from the link to your .css and .js files. from This increases your page speed. However, please note that some WordPress plugins depend on the query strings and thus will […]
Add a custom “Read More” link for excerpts of your custom post type. This example replaces the “[…]” which WordPress automatically appends to excerpts. It adds instead an ellipsis followed by “Read more →”. To add “Read more” to regular post excerpts, see Custom “Read More” Link For Excerpts in WordPress. In the sample below, […]