Example code for checking WordPress versions.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
get_bloginfo( 'version' ); | |
global $wp_version; | |
if ( version_compare( $wp_version, '4.3', '>=' ) ) { | |
// WordPress version is greater than 4.3 | |
} | |
if ( function_exists( 'has_post_format' ) ) { | |
// 3.1 specific code | |
} | |
/* | |
* Compares the version of WordPress running to the $version specified. | |
* | |
* @param string $operator | |
* @param string $version | |
* @returns boolean | |
*/ | |
function is_version( $operator = '>', $version = '4.0' ) { | |
global $wp_version; | |
return version_compare( $wp_version, $version, $operator ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment