Warning: WP_Syntax::substituteToken(): Argument #1 ($match) must be passed by reference, value given in /home/mankitse/designoak.com/wp-content/plugins/wp-syntax/wp-syntax.php on line 380
Warning: WP_Syntax::substituteToken(): Argument #1 ($match) must be passed by reference, value given in /home/mankitse/designoak.com/wp-content/plugins/wp-syntax/wp-syntax.php on line 380
Warning: WP_Syntax::substituteToken(): Argument #1 ($match) must be passed by reference, value given in /home/mankitse/designoak.com/wp-content/plugins/wp-syntax/wp-syntax.php on line 380
Warning: WP_Syntax::substituteToken(): Argument #1 ($match) must be passed by reference, value given in /home/mankitse/designoak.com/wp-content/plugins/wp-syntax/wp-syntax.php on line 380
Warning: WP_Syntax::substituteToken(): Argument #1 ($match) must be passed by reference, value given in /home/mankitse/designoak.com/wp-content/plugins/wp-syntax/wp-syntax.php on line 380
Här är ett tips för dig som vill skapa en sidopanel med länkar till de aktuella undersidorna. Rubriken blir den sida som är överst i hierarkin och under listas undersidorna. Ett exempel på hur det kan se ut kan du se här: http://www.scandcap.se/tjanster/. Även rubriken är klickbar när du är inne på undersidorna, detta gör att det är lätt att komma tillbaka till ”huvudsidan”. Koden kan placeras i sidebar.php eller om du väljer att ha den i ditt page template. Såhär ser koden ut för att skapa denna funktion:
<!--?php //parent variables $parent = get_post($post--->post_parent); $parent_title = get_the_title($parent); $grandparent = $parent->post_parent; $grandparent_title = get_the_title($grandparent);?> <!--?php // is the homepage the granparent? if ($grandparent == is_page('0')) { ?--> |
<!--?php // is the homepage the parent? } elseif ($post--->post_parent ==is_page('0')) {?> |
<!--?php // I must be a top level page! } else { ?--> |
<!--?php }?--> <!--?php if(!$post--->post_parent){ // will display the subpages of this top level page $children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0"); }else{ // diplays only the subpages of parent level //$children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0"); if($post->ancestors) { // now you can get the the top ID of this page // wp is putting the ids DESC, thats why the top level ID is the last one $ancestors = end($post->ancestors); $children = wp_list_pages("title_li=&child_of=".$ancestors."&echo=0"); // you will always get the whole subpages list } } ?> |
Lämna ett svar
Du måste vara inloggad för att publicera en kommentar.