write custom woocommerce templates and forms

To answer your second question you’ll have to properly enqueue the Bootstrap 4 styles and scripts: Including CSS & JavaScript | Theme Development From there you either have to add existing WooCommerce classes to your BootStrap CSS or add BootStrap classes to your WooCommerce templates (preferred/recommended). As for the templates, it really depends on which … Read more

Adding country tags automatically

I’d recommend making use of this API: https://www.countryflags.io/. You’ll also need a list of countries and country codes. Download that here: https://gist.github.com/keeguon/2310008 Then, you can do something like this to register all of the countries to your custom post type’s taxonomy. (you only really need to run this code once) $countries_json = file_get_contents(‘/countries.json/’); $countries = … Read more

wp_loaded hook block script enquequing

You can’t enqueue because wp_loaded is too early. To enqueue scripts and styles, you need to do it on the wp_enqueue_scripts type hooks, but because your exiting on wp_loaded, none of those hooks have fired yet. Additionally, you need to have the necessary function calls in the template for it to enqueue them into, such … Read more

Combine two filters into a single call

As long as the received arguments and the return values are the same, yes, you can combine them. add_filter( ‘manage_edit-post_columns’, ‘my_columns_callback’ ); add_filter( ‘manage_edit-recipe_columns’, ‘my_columns_callback’ ); function my_columns_callback( $columns ) { $columns[‘author’] = ‘User’; return $columns; }

WP add_action factory

Check out the php callable manual. A PHP function is passed by its name as a string. Any built-in or user-defined function can be used, except language constructs such as: array(), echo, empty(), eval(), exit(), isset(), list(), print or unset(). However, in your code sample you are using an anonymous function, which can be passed … Read more

Customize Time Stamp

In this updated version of meks_time_ago(), the human readable date/time will be returned if the published date was less than the $threshold of days ago. Otherwise, the full date and dime will be returned. function meks_time_ago( $days_threshold = 3 ) { $published_date_timestamp = get_the_time( ‘U’ ); $current_date = new DateTime(); $published_date = new DateTime( “@$published_date_timestamp” … Read more

Importing hard coded custom field into acf field

First off, you should know that get_post_meta() doesn’t create any custom fields (or metadata), it only retrieves the custom field’s value. But the WordPress functions that do create custom fields (for posts) are add_post_meta() and update_post_meta(). So that get_post_meta($post->ID, “mt_post_subtitle”, true) simply retrieves the value of the meta/field named mt_post_subtitle for the post (referenced by … Read more