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

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?

list taxonomy terms in current post / current category

You can try this: /** * List the taxonomies and terms for a given post * * @param int $post_id * @return string */ function get_the_current_tax_terms_wpse( $post_id ) { // get taxonomies for the current post type $taxonomies = get_object_taxonomies( get_post_type( $post_id ) ); $html = “”; foreach ( (array) $taxonomies as $taxonomy) { // …

Read more

is action hook not working on quick edit?

According to WPSeek’s page on the create_{$taxonomy} action hook, and also the new-to-me WordPress Developers’ docs on the same hook, there are two required parameters: Parameters $term_id (int) (Required) Term ID. $tt_id (int) (Required) Term taxonomy ID. So your function is missing the $tt_id parameter.

How we retrieve the ‘tags’ and ‘attachment’ of the custom post which is created by wp_insert_post();

You can use: $post_id = wp_insert_post($args); to get the ID of the inserted post. You can try this: $terms = wp_get_object_terms($post_id, ‘thread_tag’); to get the terms from your post with $post_id. You can check out the Codex: You can then use get_children() $args = array( ‘post_mime_type’ => ‘image’, ‘post_parent’ => $post_id, ‘post_type’ => ‘attachment’ …

Read more

Attempting to filter posts using get_terms

Have you tried out isotope? I am working on a project that needs a similar function. So far it’s the closest I’ve found that will sort/filter posts. The link – Here’s some questions I had about implementing it with wordpress, and was able to do so to certain extent. It can help get you …

Read more