function my_wp_nav_special_classes($classes, $item)
{
    //if( $item->object_id == page_chalets() ) {
    //        $classes[] = 'section-chalets';
    //}
    if ($item->object_id == get_root_parent_id()) {
        $classes[] = 'is-root-parent';
    }
    return $classes;
}
function get_root_parent_id($post_id = null)
{
    if (!$post_id) {
        global $post;
        $post_id = $post->ID;
    }
    global $wpdb;
    $parent = $wpdb->get_var("SELECT post_parent FROM {$wpdb->posts} WHERE post_type='page' AND post_status='publish' AND ID = '{$post_id}'");
    if ($parent == 0) {
        return $post_id;
    } else {
        return get_root_parent_id($parent);
    }
}
function get_insection_subnav($post_type = 'page')
{
    global $post;
    // test for subnav
    if ($post_type == 'page') {
        $sub_level_1 = get_sub_pages(get_root_parent_id($post->ID));
    } else {
        $sub_level_1 = get_root_pages($post_type);
    }
    // if pages to display
    if ($sub_level_1) {
        return $sub_level_1;
    } else {
        return false;
    }
}
Beispiel #4
0
function get_root_parent_id($parent_id)
{
    if ($parent_id != 0) {
        $parent_id = wp_get_post_parent_id($parent_id);
        get_root_parent_id($parent_id);
    } else {
        $parent_id = get_the_ID();
    }
    return $parent_id;
}
				<div class="sidebar" role="complementary">
					<?php 
if (get_insection_subnav()) {
    ?>
					<nav class="panel">
						
						<h2>
							<?php 
    wp_reset_postdata();
    link_by_id(get_root_parent_id($post->ID));
    ?>
						</h2>
						<?php 
    insection_subnav('page', 'is-current');
    ?>
					</nav>
					<?php 
}
?>
					<?php 
$sidebar_panels = new WP_Query(array('connected_type' => 'connect_panels', 'connected_items' => get_queried_object_id(), 'nopaging' => true));
if (function_exists('p2p_register_connection_type') && $sidebar_panels->have_posts()) {
    while ($sidebar_panels->have_posts()) {
        $sidebar_panels->the_post();
        ?>
					<article class="panel">
						<?php 
        the_post_thumbnail('panel-thumb', array('class' => '', 'title' => ''));
        ?>
						<h2><?php 
        the_title();