How to get tags only with custom meta field and display them randomly?

You can get custom fields randomly using the below code that you can combine with your existing code to get desired output. function wpll_get_popular_nodes() { global $wpdb; $custom_fields = $wpdb->get_results( “select DISTINCT meta_value from $wpdb->postmeta pt LEFT JOIN $wpdb->posts p ON (pt.post_id = p.ID) where meta_key LIKE ‘tax_image_url_universal’ ORDER BY RAND()” ); if ( is_array( …

Read more

How can I filter get_terms with post meta

If you want to output a list of terms that are assigned to the posts in the current query, you could use something like this in your template: global $wp_query; $terms = []; foreach ( $wp_query->get_posts() as $item ) { $item_terms = wp_get_post_terms( $item->ID, ‘web_cat’ ); $terms[] = $item_terms; } $unique = array_unique( array_merge(…$terms), SORT_REGULAR …

Read more

get_the_term_list give me a whitespace

I wonder if you got any term_links-genre filters that could be modifying your get_the_term_list() output? Your code example should in general work as expected, but you might want to use the get_the_terms() function to better control the output to your own likings. Here’s a modifed version of the corresponding Codex example: /** * Customized the …

Read more

Custom WordPress Excerpt within terms

I’ve used code like this, based (extremely) loosely on the plugin relevanssi: (in “functions.php”) // Roughly based on the relevanssi_do_excerpt() (, GPLv2 or later), seriously simplified. function mytheme_search_context( $haystack, $needles, $len = 30 ) { $ret=””; $haystack = strip_tags(mytheme_strip_invisibles($haystack)); $haystack = trim( preg_replace( array( “/\n\r|\r\n|\n|\r/”, ‘/\s\s+/’, ‘/&.{1,30}?;/’ ), ‘ ‘, $haystack ) ); $words = …

Read more

How to solve/debug get_terms suddenly showing no results?

Prior to 4.5.0, the first parameter of get_terms() was a taxonomy or list of taxonomies: Since 4.5.0, taxonomies should be passed via the taxonomy argument in the $args array: So, the lines /** * Get the family */ $args = array( ‘parent’ => $topmost->term_id, ); $family = get_terms($taxonomy_name, $args); should be /** * Get the …

Read more

Relate term to term?

Wow, it just works… I can use wp_set_object_terms() to set a term to a term… $term_taxonomy_ids = wp_set_object_terms( $bill_term_id, $microsoft_term_id, ‘company’ ); And I can retrieve the company connected to a person with wp_get_object_terms like… $bills_company_terms = wp_get_object_terms($bill_term_id, ‘company’); The only thing is, how can I put a backend interface on these relationships?