Skip to content

Instantly share code, notes, and snippets.

@tollmanz
Created May 21, 2012 03:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tollmanz/2760476 to your computer and use it in GitHub Desktop.
Save tollmanz/2760476 to your computer and use it in GitHub Desktop.
Get a Unique Key for Current Object
<?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