0

I need to read some theme options before add_image_size is executed so I changed the action priority to 9 instead of the default 10

add_action( 'after_setup_theme', '_my_action_add_image_sizes',9 );

do you think there would be some issues with this ?

  • You don't really show enough code to answer well. Can't _my_action_add_image_sizes just read the options and then call add_image_size after ? – Andy Macaulay-Brook Jun 8 '17 at 18:19
0

You can set the priority to 999 to make sure if you are going that way:

add_action( 'after_setup_theme', '_my_action_add_image_sizes', 999 );

but if you really want to make sure of that order, try making a custom action, here a small example:

/**
 * Execute the action with do_action.
 */
 function read_theme_options() {
   //all the logic you want to execute before adding image sizes here

   do_action( 'my_action' );//do the action
 }

 /**
  * Register the action, you can add the functions you want to the action
  */
  add_action( 'my_action', '_my_action_add_image_sizes' );
  function _my_action_add_image_sizes() {
    //adding images here
  }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.