post_parent) { $ancestors=get_post_ancestors($post->ID); $root=count($ancestors)-1; $parent = $ancestors[$root]; } else { $parent = $post->ID; } return $parent; }; /** * Get excerpt from string * * @param String $str String to get an excerpt from * @param Integer $startPos Position int string to start excerpt from * @param Integer $maxLength Maximum length the excerpt may be * @return String excerpt */ function getExcerpt($str, $startPos=0, $maxLength=100) { if(strlen($str) > $maxLength) { $excerpt = substr($str, $startPos, $maxLength-3); $lastSpace = strrpos($excerpt, ' '); $excerpt = substr($excerpt, 0, $lastSpace); $excerpt .= '...'; } else { $excerpt = $str; } return $excerpt; } /* add_action( 'init', 'cd_add_editor_styles' ); function cd_add_editor_styles() { add_editor_style( get_stylesheet_directory_uri().'/assets/stylesheets/foundation.css' ); } function my_theme_add_editor_styles() { global $post; $post_type = get_post_type( $post->ID ); $editor_style = get_stylesheet_directory_uri().'/assets/stylesheets/foundation.css'; add_editor_style( $editor_style ); } add_action( 'pre_get_posts', 'my_theme_add_editor_styles' ); var_dump( get_stylesheet_directory_uri().'/assets/stylesheets/foundation.css' ); */ function wpb_list_child_pages($child_type) { global $post; $childpages = wp_list_pages( array( 'sort_column' => 'menu_order', 'title_li' => '', 'child_of' => wp_get_most_parent(), 'echo' => 0, 'depth' => 1 ) ); if ( $childpages ) { $string = ''; } return $string; } function button_1( $href, $button_text, $attributes ) { if ( !isset( $button_text ) ) { $button_text = 'Mehr erfahren'; }; $button = '
'. $button_text .'
'; return $button; }; // Usage: // get_id_by_slug('any-page-slug'); function get_id_by_slug($page_slug) { $page = get_page_by_path($page_slug); if ($page) { return $page->ID; } else { return null; } } add_action( 'wp', 'post_pw_sess_expire' ); function post_pw_sess_expire() { if ( isset( $_COOKIE['wp-postpass_' . COOKIEHASH] ) ) // Setting a time of 0 in setcookie() forces the cookie to expire with the session setcookie('wp-postpass_' . COOKIEHASH, '', 0, COOKIEPATH); }