Can priority of “init” actions be reduced (for taxonomies)?
-
I’m using block_lab_add_field, in the block_lab_add_blocks action (as per the docs).
In my associated function, I want to populate the options in a <select> field with the names of the terms in a particular taxonomy.
Problem – I can’t use get_terms() for this, because the hook runs so early in WP’s init() action. I tracked down the line in class-loader.php, which says:
add_action( ‘init’, $this->get_callback( ‘retrieve_blocks’ ), 1 );That priority “1” is the issue – it means that the taxonomies haven’t yet been set up, so get_terms() just returns an error. If I change the priority to “10”, then my code works OK. Obviously, I’ve reverted to “1” now, lest it causes any issues for Block Lab.
I’m having to work around this by doing a wp_query to the database, so it’s kind of OK, but it would be better to be able to use get_terms().
Is there a reason for the high priority 1 as things stand? Could it change to something like 10?
- The topic ‘Can priority of “init” actions be reduced (for taxonomies)?’ is closed to new replies.