paginate_links with select option

Here is the snippet for archive navigation with previous and next link along with the select dopwdown. Select will contain the list of all pages and page url as value of option. onChange is used to redirect page when select option is changed. You can use following code and modify as per your need. function … Read more

How to add another ordercomments field to woocommerce checkout

To add another order notes custom fields : add in functions.php : /** * add new order note field */ add_filter( ‘woocommerce_checkout_fields’ , ‘customizing_checkout_fields’, 10, 1 ); function customizing_checkout_fields( $fields ) { // Define new custom Order Notes field data array $customer_note = array( ‘type’ => ‘textarea’, ‘class’ => array(‘form-row-wide’, ‘notes’), ‘label’ => __(‘Order Notes … Read more

Layout Settings in the new Gutenberg editor

For a very basic implementation of adding a text input to add body classes(would also work for adding a second field for post classes if necessary) to pages/posts, you could do the following: Register a custom field with register_post_meta – I’ll use an empty string for the first param, post_type so it applies to all. … Read more

How do I access the contents of WordPress Classic editor in admin area with JavaScript?

To get the editor content as a string in the classic editor use this: content = tinymce.activeEditor.getContent(); Taken from https://stackoverflow.com/a/5843951/57482 Note that you should use the APIs provided rather than directly modifying the DOM if you want to modify the content. If you don’t, you won’t update plugins local states in javascript causing problems. Modifying … Read more

wp_mail vs mail functions and header arrays

Both the mail() function in PHP and wp_mail() in WordPress do support passing an array or string of headers, but the difference is: With mail(), the array keys are the header names and its values are the respective header values, e.g. array( ‘Content-type’ => ‘text/html; charset=utf-8’ ). wp_mail() on the other hand, expects that the … Read more

On archive.php show loop for child categories if they exist or posts if they don’t, on custom post type

This works, anything better would be appreciated $term = get_queried_object(); $term_id = $term->term_id; $taxonomy_name = $term->taxonomy; $termchildren = get_term_children( $term_id, $taxonomy_name ); if (!empty($termchildren)) { echo ‘<div class=”subcatwrapper”>’; echo ‘<ul class=”workshopgrid centerWidth”>’; foreach ( $termchildren as $child ) { $term = get_term_by( ‘id’, $child, $taxonomy_name ); echo ‘<li class=”workshopbox”>’; echo ‘<div class=”workshopimage”><a href=”‘. get_term_link( $term->slug, … Read more