WordPress development tutorials

Screen ID checks with WordPress Submenu Pages

Chances are if you’ve read our series on adding plugin settings to WooCommerce, you’re using an existing WooCommerce settings page or new settings tab to add any required configuration options for your plugin. If you have a more complex plugin who’s data will be accessed very often (such as Memberships or Subscriptions), you may even be adding a new submenu with a custom settings or usage page for your plugin. However, we’ve run into any…

Read More

WordPress development tutorials

How to Generate a Post Excerpt Outside the Loop

When you work with WordPress, you become pretty familiar with using the WP_Post object or objects for custom post types. For example, while working with WooCommerce, products use the WC_Product post object (or the object for a class that inherits this, such as WC_Product_Variation). If you’re in the loop while working with posts or custom post types, get_the_excerpt() is a beautiful function, as it returns the excerpt if it’s set by the user, and automatically…

Read More

WordPress development tutorials

How to Create a WordPress Shortcode

Shortcodes are a great feature of WordPress, and many plugins include their own handy shortcodes. For example, WooCommerce includes several shortcodes. These can allow you to create “Buy Now” buttons, insert products into blog posts, display related products or featured products, and more. While these shortcodes are really helpful, as are the shortcodes included by most plugins or extensions, it’s still very useful to create a WordPress shortcode for your own use. For example, I…

Read More

WordPress development tutorials

How to apply changes to a single WordPress page

Here’s a quick development tutorial on how to make changes to a single WordPress page or post. Let’s say that you want to change styling for one page on your site, but it doesn’t have unique class or ID for you to target in your stylesheet. You can use the is_page() conditional tag to target a specific WordPress page to make your changes. You can also use the is_single() tag to target an individual post…

Read More

Add Custom Code to WordPress

How to Safely Add Custom Code to WordPress Sites

There are many times that you want to tweak plugins, add a code snippet, or change some styling for your WordPress site. However, many users make these changes in a way that’s not viable for the long-term. For example, these changes shouldn’t be put into your parent WordPress theme, as they’ll be overridden when you update your theme (the same goes for plugins). Some users use this as a reason not to update themes or…

Read More

Down the Rabbit Hole: WordPress and Timezones

“Why, sometimes I’ve believed as many as six impossible things before breakfast.” ― Lewis Carroll, Alice in Wonderland A few months ago, we were working on the WooCommerce Pre-Orders extension and had to think about how we wanted to store the release date & time. Like most concepts that look simple and easy at first, this turned out to be somewhat complex. Throughout development, I ended up learning quite a bit about working with timezones…

Read More

WordPress development tutorials

Translating a WordPress Plugin on the Command Line Step by Step

The purpose of this article is to provide a quick and easy to follow step-by-step guide to extracting text strings from a WordPress plugin for translation from the command line. Although this is documented in the codex: I18N for WordPress Developers and Translating WordPress, those articles are somewhat lengthy and the first time I was asked to internationalize a plugin it took me some time to find the actual steps to generate my POT file….

Read More

WordPress development tutorials

WordPress Get DB Table Column Names

To get the column names for a MySQL database table in WordPress, use the following: global $wpdb; $table_name = $wpdb->prefix . ‘posts’; foreach ( $wpdb->get_col( “DESC ” . $table_name, 0 ) as $column_name ) { error_log( $column_name ); } Which will result in something like the following being printed to your debug.log: ID post_author post_date post_date_gmt post_content … You get the idea

Read More

Don’t Share Terms Between WordPress Taxonomies

By default WordPress will reuse terms with the same name and slug between different taxonomies (at least for now). For instance, if you add the term ‘red’ as a tag, and then add the category ‘red’, the same wp_terms record will be shared between them. This is also true for any custom taxonomies you define (remember that despite their seeming differences, WordPress tags and categories are both implemented as taxonomies). Now, in general this is…

Read More

WP Development

Extending the WordPress XML-RPC API

The purpose of this article is to describe the WordPress XML-RPC API, explain how to use it, and demonstrate how to extend it to create custom API methods for interacting programmatically with WordPress. I assume a relative unfamiliarity with XML-RPC in general, WordPress XML-RPC, and spend time first covering the basics, if you want to skip straight to the section on extending the WordPress XML-RPC API, feel free to. What is XML-RPC? As defined by…

Read More

Error: Please enter a valid email address

Error: Invalid email

Error: Please enter your first name

Error: Please enter your last name

Error: Please enter a username

Error: Please enter a password

Error: Please confirm your password

Error: Password and password confirmation do not match