Get URL of a specific file

See Determining Plugin and Content Directories. plugins_url( ‘filename’, __FILE__ ); … returns the full URI to the file in your plugin. For themes you use: get_stylesheet_directory_uri() . ‘/path/to/file’;

Hide a theme on list of themes in wp-admin without editing core files

The following filter works in Multisite in the following screens: /wp-admin/network/themes.php /wp-admin/network/site-themes.php?id=1 (individual sites allowed themes) add_filter( ‘all_themes’, ‘wpse_55081_remove_themes_ms’ ); function wpse_55081_remove_themes_ms($themes) { unset($themes[‘Twenty Ten’], $themes[‘Twenty Eleven’]); return $themes; } For the regular theme selector in a single site or sub-site of a network /wp-admin/themes.php (Appearance -> Themes), looks like there’s no hook… Manipulate list … Read more

add image size still doesn’t work even after regenerating thumbnails

There are a couple of things to check here. First, make sure that add_theme_support( ‘post-thumbnails’ ) is loaded before add_image_size( ‘small-thumb’, 60, 60, true ) You can always hook everything through a function to the after_setup_theme hook. I always add these in my theme setup function function wpse_setup_theme() { add_theme_support( ‘post-thumbnails’ ); add_image_size( ‘small-thumb’, 60, … Read more

How to remove “Proudly powered by WordPress” in Twenty Sixteen (2016) theme?

The quick and dirty way would be to either delete the two lines that are ‘resposible’ for the message, or wrap them by comments / comment-them-out. In your theme folder ‘twentysixteen’ look for the theme file ‘footer.php’ Around line 50 look for the following two lines: <span class=”site-title”><a href=”https://wordpress.stackexchange.com/questions/230348/<?php echo esc_url( home_url(“https://wordpress.stackexchange.com/” ) ); ?>” … Read more

Building useful features into your theme

It’s all site-dependent. I have a few core things I build in to any theme’s functions.php though: Change logo on admin page to suit the client’s company Hide WP-Stats smiley graphic Hide WP.me short URLs and replace with their chosen provider Add option for Twitter, Facebook, and Buzz buttons and ability to pull in Tweets … Read more

Is it possible to stop a theme activation when a certain plugin is not activated

Using after_switch_theme will activate the theme (which is fine as we want to run the check within the context of the new theme). If the dependencies are not fulfilled ($missing_dependencies = true;) we’re instantly switching back to the theme previously used (passed via after_switch_theme and $oldtheme). add_action( ‘after_switch_theme’, ‘check_theme_dependencies’, 10, 2 ); function check_theme_dependencies( $oldtheme_name, … Read more

Add colors to existing color palette without replacing it

You can merge palettes $existing = get_theme_support( ‘editor-color-palette’ ); $new = array_merge( $existing[0], array( array( ‘name’ => __( ‘Strong magenta’, ‘themeLangDomain’ ), ‘slug’ => ‘strong-magenta’, ‘color’ => ‘#a156b4’, ), array( ‘name’ => __( ‘Light grayish magenta’, ‘themeLangDomain’ ), ‘slug’ => ‘light-grayish-magenta’, ‘color’ => ‘#d0a5db’, ), )); add_theme_support( ‘editor-color-palette’, $new);