Copy/clone/associate Custom field to Custom Taxonomy

Here is a simple plugin with the convert function from the plugin you linked and a simple WordPress cron setup to run daily just make sure you change CUSTOM_FIELD_KEY and TAXONOMY_NAME to the actual values <?php /* Plugin Name: wpse62432 Plugin URI: http://en.bainternet.info Description: Answer to http://wordpress.stackexchange.com/questions/62432/copy-clone-associate-custom-field-to-custom-taxonomy Version: 1.0 Author: bainternet Author URI: http://en.bainternet.info */ … Read more

Trying to add taxonomy to get_categories() but it’s not working. How to fix this?

Use : $terms = get_terms( ‘location’, ‘hide_empty=0′ ); if(is_wp_error($terms)){ // error occurred } else if (empty($terms )){ // no terms were found } else { // process terms foreach($terms as $term){ // process this individual $term } } I’d advise you use the generic taxonomy & term functions everywhere, and avoid the special case category … Read more

Website loading slowly – Advanced Custom Fields images

I have managed to work it out – the function was leading to a lot of queries, so I rewrote it as follows: $housePhotos = get_post_custom_values(‘house_photos’); $housePhotos = explode(‘;’,$housePhotos[0]); preg_match_all(‘`”([^”]*)”`’, $housePhotos[1], $results); $imageURL = wp_get_attachment_image_src( $results[1][0], ‘house_search’ ); if (!empty($results[1][0])) { echo ‘<img src=”‘ . $imageURL[0] .'” alt=”” />’; }

WP_Query parameter conflict

Is your post type non-hierarchical like a post – or hierarchical like a page? It will determine which slug parameter you should be using in WP_Query: name (string) – non-hierarchical (post) slug. pagename (string) – hierarchical (page) slug. Also, the tax_query should have the operator parameter. Possible values are ‘IN’, ‘NOT IN’, ‘AND’. You should … Read more

Display custom posts randomly in custom taxonomy archive

I’ve finally found the solution thanks to a friend of mine: exploiting get_queried_object() we can set the object name in the script as follows: <?php $obj=$wp_query->get_queried_object(); $args=array( ‘tax_query’ => array( array( ‘taxonomy’ => ‘areas’, ‘field’ => ‘slug’, ‘terms’ => $obj->name ) ), ‘orderby’ => ‘rand’ ); query_posts($args); ?> Hope this can help. Enjoy! 🙂