All posts ordered by popularity
WordPress makes it easy to get the current user’s role(s) by using wp_get_current_user(). But what if you want to get all roles from all users. Like a list of every role that is used on your site. Well good news, WordPress provides a global object named $wp_roles that provides the information. So if you’re looking […]
Here is a function used in my free WordPress plugin User Submitted Posts that enables you to rename WordPress media uploads. So for example, if the user uploads a JPG image named “sweet-ride.jpg”, the following function will append a random string to rename the file “sweet-ride-random.jpg”, where “random” is a random alphanumeric string containing 20 […]
Normally the “Screen Options” tab is an awesome little WordPress feature. Located on various screens in the WP Admin Area, the Screen Options tab toggles open any available settings. Like which meta boxes to display, layout columns, editor auto-height, and other options depending on which screen you are viewing. But there may be cases where […]
In WordPress, you can create posts, pages, or any custom post type. Within your theme template, you can get the current post type using the core WP function, get_post_type(). But that doesn’t work in the Admin Area. For example, my Disable Gutenberg plugin provides conditional functionality to the “Add New” and “Edit” screens based on […]
Working on my plugin Disable Gutenberg, I needed a way to get the ID of an edited post. Not on the front-end, but on the “Edit Post” screen in the WP Admin Area. Unfortunately WordPress does not provide a built-in core function for handling this, so it’s necessary to roll our own solution.
I’ve posted before about fixing weird default browser styles. It happens all too often. Well-intentioned browser developers taking liberties on the page with things like CSS styles. This post shares a quick code snippet that fixes the Chrome browser’s new “rounded corners” style that now is applied to form elements like buttons and inputs.
It’s easy to style a <div></div> by targeting its ID. But what if you only want to add style when a specific fragment identifier is targeted via the URL? So for example, your page at /about/ has a table with all the data. When visitors arrive directly at /about/, no extra styles are added. But […]
Depending on your WordPress configuration, plugins, and so forth, your site may be suffering from “self-pings”. Self-pings are pingbacks from your own domain, which are not necessary and look kind of silly displayed alongside other, actual pingbacks. If your site is haunted by self-pings, here is a quick code snippet to stop them.
Quick code snippet showing basic use of the WordPress template_redirect action hook. This is provided as a quick copy/paste reference for WordPress developers. This hook is useful for customizing any functionality requiring full query information.