Benutzer-Werkzeuge

Webseiten-Werkzeuge


snippets:wp:get_post_id

Inhaltsverzeichnis

WordPress: get_post_id

if( !function_exists( 'ui_get_post_id' ) ):
	/**
	 * @see http://wordpress.stackexchange.com/a/220624
	 */
 
	function ui_get_post_id( $default = 0 ) {
		$return = $default;	
 
		$current_post = sanitize_post( $GLOBALS['wp_the_query']->get_queried_object() );
 
 
		if( !empty( $current_post) && !empty( $current_post->ID ) ) {
			$return = $current_post->ID;
		}
 
		return $return;
	}
 
endif;

Quelle

snippets/wp/get_post_id.txt · Zuletzt geändert: 29.03.2017 17:44 von fwolf