WooCommerce get_price returning wrong price when used via ajax

It’s important to exit the function when using the wp_ajax hooks. Hopefully this fixes it. function get_ticket_price() { $ticketID = $_REQUEST[‘ticketID’]; echo wc_get_product( $ticketID )->get_price(); // Don’t forget to stop execution afterward. wp_die(); } add_action( ‘wp_ajax_get_ticket_price’, ‘get_ticket_price’ ); add_action( ‘wp_ajax_nopriv_get_ticket_price’, ‘get_ticket_price’ );

WP plugins for building a database?

WordPress natively stores content in a database. It sounds like you’re wanting to store info in that database, and retrieve and present it – rather than actually create a separate database. If that’s the case, creating custom post types are likely the way to go. An author can be a custom post type, which would … Read more

Where to call add_shortcode function in WordPress Plugin Boilerplate?

If you look at the /includes/class-plugin-loader.php you will see the public function add_shortcode( $tag, $component, $callback, $priority = 10, $accepted_args = 2 ) { $this->shortcodes = $this->add( $this->shortcodes, $tag, $component, $callback, $priority, $accepted_args ); } That builds a list of shortcodes to be registered with WordPress. You use that via /includes/class-plugin.php within this function: /** … Read more

How do I modify the position of a plugin?

It’s always bad practise to modify a plugin file. For one thing you will lose your changes when the plugin is updated. Look to see if your plugin has been created with filters (good plugins should be). Search within your plugin for “apply_filters(” – With luck you will find this near the positional code. It … Read more

Changing labels of status filters for post grid

Here’s an untested way to override it, based on my older answer: add_action( ‘init’, function() { $vars = get_object_vars( get_post_status_object( ‘draft’ ) ); $vars[‘label_count’] = _n_noop( ‘Disabled <span class=”count”>(%s)</span>’, ‘Disabled <span class=”count”>(%s)</span>’, ‘wpse-domain’ ); register_post_status( ‘draft’, $vars ); }, 1 ); We use the priority 1, since the default draft status is registered at priority … Read more

Plugin upgrade issue

How to clear the “Briefly unavailable for scheduled maintenance” message after doing automatic upgrade? As part of the automatic upgrade WordPress places a file named .maintenance in the blog base folder (folder that contains the wp-admin folder). If that file exists, then vistors will see the message Briefly unavailable for scheduled maintenance. Check back in … Read more

An issue with SEO Ultimate

Check the referring URL and the user agent. Usually these are caused by robots that found a link to the draft or happened to be scanning your site while you were previewing the posts. I wouldn’t worry about it unless it was an actual user that was getting the error.