Permanently activate WordPress theme

Here’s one idea: /** * Reactivate the sticky theme, if someone activates another theme. */ add_action( ‘switch_theme’, ‘wpse_permanent_theme’ ); function wpse_permanent_theme( $new_name ) { $sticky_theme_name=”twentyfifteen”; // Modify this to your needs! // Get the sticky theme info, to check if it exists (named): $sticky_theme = wp_get_theme( $sticky_theme_name ); // Reactivate the sticky theme: if( $sticky_theme->get( … Read more

How to Get Current Custom Post Type Associated Taxonomy Term

// First, get associated taxonomies of the post/object. $object_taxonomies = get_object_taxonomies( get_post() ); // Next, get associated terms of the post/object. $object_terms = wp_get_object_terms( get_the_ID(), $object_taxonomies ); $terms = array(); // returned object terms could be WP_Error, so check that first. if( ! is_wp_error($object_terms) && is_array($object_terms) ) { foreach( $object_terms as $object_term ) { // … Read more

Compare the old get_theme_mod($name) to the new get_theme_mod($name) return value

One of the solutions that I’ve found, is to store the set get_theme_mod($name) into a PHP $_SESSION[“$name”]. If the session exist, compare the new get_theme_mod($name) to that old $_SESSION[“$name”], if they’re not the same then // do something..: // Check if the user is an admin for validation to improve performance. if (current_user_can( ‘manage_options’ )) … Read more