Created
May 21, 2012 03:47
-
-
Save tollmanz/2760476 to your computer and use it in GitHub Desktop.
Get a Unique Key for Current Object
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 a unique ID key for current $wp_the_query object. | |
* | |
* @return string|int unique key on success, 0 on failure | |
*/ | |
function zdt_get_object_key() { | |
$queried_object = get_queried_object(); | |
$queried_object_id = get_queried_object_id(); | |
if ( ! is_null( $queried_object ) && $queried_object_id > 0 ) | |
return md5( serialize( $queried_object ) . $queried_object_id ); | |
else | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment