display ACF repater field in archive page
get_field() and have_rows() work with post/term ID, not the whole “queried object“. You should try $term = get_queried_object()->term_id; in line 1. Also it is unnecessery to set $term again at line 3.
get_field() and have_rows() work with post/term ID, not the whole “queried object“. You should try $term = get_queried_object()->term_id; in line 1. Also it is unnecessery to set $term again at line 3.
Can you try to escape the variable $post_id? Like so: ”.$post_id.” So use the single quote twice. You are querying a slug and your variable is a number.
$_POST sometimes empty even though isn’t when using edited_[taxonomy] hook
How can I order a post query’s results based on the number of matching taxonomy terms?
For some reason the add_action( ‘pre_get_posts’, ‘category_custom_orderby’ ); hook isn’t working. Yes, and it’s because on the Categories admin page (where you can see the Categories list table), the list table uses WP_Term_Query and not WP_Query, hence the above hook (pre_get_posts) is not fired. So instead of the above add_action(), try using the parse_term_query hook … Read more
wp_insert_term doesn’t want to enter its data into custom taxonomy
I figured it out: update_term_meta( $term_id, ‘organization’, $_POST[‘organization’], true ); should have been update_term_meta( $term_id, ‘organization’, $_POST[‘organization’] ); Where the fourth parameter makes it unique.
automatically select taxonomy based on post meta
So I came up with a workaround solution. Not sure if it is the fastest and best solution but it works perfectly fine for our custom field. This works with custom post types and custom taxonomies and sorts everything A->Z. Any better solution? // get all posts from custom post type and their TERMS // … Read more
If you have a need to build up an actual structure of terms, this might be a useful method for you: /** * Recursively sort an array of taxonomy terms hierarchically. Child categories will be * placed under a ‘children’ member of their parent term. * @param Array $cats taxonomy term objects to sort * … Read more