1

Is it a bad idea to set your themename and shortname as variables to be used in the various functions of a theme?

Example:

$themename = mytheme;
$shortname = mth;

/**
 * Get our wp_nav_menu() fallback, wp_page_menu(), to show a home link.
 */
function toolbox_page_menu_args($args) {
    // some code
}
add_filter( 'wp_page_menu_args', $themename . '_page_menu_args' );
1

You can do it easier and without polluting the global namespace: get_option('template'); gives you the (parent) themes name. If you want the child themes name, use get_current_theme();.

You could also use a constant across your theme files: define( 'YOUR_PREFIX-THEME_NAME', get_current_theme() );

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.