Define constants for easy development

No need to remember long paths or infinitely add …/…/…/

//Get theme dir
define(‘td’, get_bloginfo(‘template_directory’).’/’ );
//Get home dir
define(‘hd’, esc_url(home_url( ‘/’ )));
//Get temes path
define(‘tp’, get_template_directory(’’).’/’);
//Get home path
define(‘hp’, get_home_path());

Read-only archive:

Author: Nodws

Vote count: 7

Status: open


  • request-add-feature
  • difficulty-moderate


Based on the comments on this petition it seems that this is not what the core needs. If there is a need to remember long paths or any other large strings, etc. the two good options are:

1 Like

IMO, the concept of doing things for easy development is questionable.
Whether it’s a constant (please no!) or a variable, it needs to flexible, so the present function calls are best suited for this.
My use case was years ago, when making a child theme for a popular theme, I needed it to define the constants for having no default header image before the theme’s setup function did its thing which triggered the constants for a header image. But I didn’t want to have to redo all the other setup in the function. I ended up filtering the template directory function so it could pick up the child stuff instead of the parent, just for that. If that were in a constant or unfiltered variable, it would never have worked.
This experience influenced me to write a lot of warnings in theme reviews for authors to not define constants for paths and urls, but to use the functions so they could be filtered. (especially important for themes due to child themes)


This topic was automatically closed after 5 days. New replies are no longer allowed.