Extending wordpress search to include excerpts and taxonomies?

With WordPress 4.2.2 I’m using the following (admittedly fragile) method to search excerpts as well as the content and title without a plugin. This is the relevant snippet from functions.php. add_filter(‘posts_where’, ‘custom_posts_where’); function custom_posts_where($where) { if (is_search()) { $where = preg_replace( “/(\w+).post_title LIKE (‘%.*?%’)/”, “$1.post_title LIKE $2) OR ($1.post_excerpt LIKE $2”, $where); } return $where; … Read more

How to add custom field to custom taxonomy in 4.4

You can implement this in two ways to add meta boxes through plugin or wordpress predefined hooks https://wordpress.org/plugins/taxonomy-metadata/ **OR** Add the following code in functions.php in your theme function mj_taxonomy_add_custom_meta_field() { ?> <div class=”form-field”> <label for=”term_meta[class_term_meta]”><?php _e( ‘Add Class’, ‘MJ’ ); ?></label> <input type=”text” name=”term_meta[class_term_meta]” id=”term_meta[class_term_meta]” value=””> <p class=”description”><?php _e( ‘Enter a value for this … Read more

Woocommerce custom taxonomies page

After digging all over the place, it really was as simple as adding theme support. Go figure, just add the following: //Adding theme support function mytheme_add_woocommerce_support() { add_theme_support( ‘woocommerce’ ); add_theme_support( ‘wc-product-gallery-zoom’ ); //Only if want woocommerce built in add_theme_support( ‘wc-product-gallery-lightbox’ );//Only if want woocommerce built in add_theme_support( ‘wc-product-gallery-slider’ );//Only if want woocommerce built in … Read more

How can I display all post IDs from the taxonomy?

Just some code to get started. This will get you all the IDs for job_listings that are assigned to term 4 in your taxonomy. <?php $posts = get_posts( array( ‘posts_per_page’ => -1, ‘fields’ => ‘ids’, ‘post_type’ => ‘job_listing’, ‘tax_query’ => array( array( ‘taxonomy’ => ‘agency’, ‘field’ => ‘term_id’, ‘terms’ => 4 ) ) ) ); … Read more

WPML Translating a term/taxonomy programmatically

Ok I found the solution. Actually taxonomy name on icl_translation table is stored with prefix called “tax_” which means taxonomy. The above code would work like this: $trid = $sitepress->get_element_trid($englist_term_id, “tax_taxonomy_name”); $sitepress->set_element_language_details($new_term_id, “tax_taxonomy_name”, $trid, $lang_code, $sitepress->get_default_language()); The difference is tax_ prefix. Cheers!