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

Get access to all terms associated to each post that the wp_query loop displays

If I understood you correctly, you are looking for get_the_terms(), which.. Retrieves the terms of the taxonomy that are attached to the post. You could for example have helper functions like these, // functions.php function my_sports_post_terms( int $post_id ) : array { $taxonomies = [‘basketball’, ‘volleyball’, ‘baseball’]; $terms = []; foreach ($taxonomies as $taxonomy) { … Read more

How to detect if an ACF custom-field is really in use?

Most sensible here is probably just a custom query global $wpdb; $sql_find_meta = “SELECT post_id FROM database_name_here.wp_postmeta WHERE meta_key = ‘my_special_value’ AND meta_value > ”;”; // > ” == not null, whitespace or blank $posts_with_meta_key = $wpdb->get_col( $sql_find_meta ); foreach ( $posts_with_meta_key as etc….. You can repeat this for wp_termmeta and term_id

get_the_terms inside save_post gives old terms

This issue shouldn’t happen if you’re using the classic editor, however, if you’re using the block/Gutenberg editor which uses the REST API, then that issue can be fixed by using the wp_after_insert_post hook instead. Excerpt from https://make.wordpress.org/core/2020/11/20/new-action-wp_after_insert_post-in-wordpress-5-6/: The new action wp_after_insert_post has been added to WordPress 5.6 to allow theme and plugin developers to run … Read more

Unable to do WP_User_Query with meta filter

This isn’t possible, you can’t safely/reliably query the internals of meta value strings that way, and you can’t use it as a form of indirection: You can query for substrings or for whole values, but you can’t query the internals of serialised PHP values without major performance reliability and consistency issues but if you could, … Read more