|
|||
![]()
Hallo,
ich gebe in meiner Seitenleiste eine Liste mit untergeordneten Seiten aus: Code:
<?php /* Untermenü Seitenleiste * http://codex.wordpress.org/Function_Reference/wp_list_pages#List_whole_subpages */ if (!is_search() && !is_404()) : $ancestor_title = get_the_title($post->post_ancestor); 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&sort_column=post_title"); // sort_column: post_title = ABC, menu_order = wp-admin } 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&sort_column=post_title"); // you will always get the whole subpages list } } if ($children) { ?> <div class="ym-grid"> <div class="ym-gbox"> <h6 class="ym-vtitle"><?php echo $ancestor_title; ?></h6> <ul class="ym-vlist ym-clearfix"> <?php echo $children; ?> </ul> </div> </div> <?php } endif; ?> Zur Zeit sieht das Ergebniss so aus: ![]() Was muss ich machen, damit im Titel nicht "Termine 2013" sondern "Veranstaltungen" ausgegeben wird? Ich hatte das selbe vor ein paar Wochen schon einmal im wpde.org Forum gefragt, bin allerdings bisher noch nicht weitergekommen - hier die Verlinkung in den entsprechenden Thread. |
Sponsored Links |
Sponsored Links |
|
|||
![]()
Hallo David,
Vielen Dank für deine Hilfe. Die Funktion befindet sich in der sidebar.php Ich kann allerdings erst heut Abend bzw. morgen Früh deine Vorschläge testen. Melde mich dann wieder. |
|
|||
![]()
Guten Morgen,
deine Tipps habe mir geholfen! Die Argumente hab ich jetzt auch als Array übergeben. Vielen Dank dafür. Eine Frage ist bei dem ganzen allerdings noch aufgetaucht: Im ursprünglichen Skript wurden die Vorfahren mit $post->ancestors abgerufen. Wenn ich einen var_dump auf $post mache, gibt es da kein Feld ancestors - Woher stammt diese die Information? Ich habe jetzt zum besseren Verständnis das ganze mit get_post_ancestors() gelöst. Beide Wege haben den gleichen Inhalt (in meinem Fall ein Array mit 2 ID's). [PHP] Untermenü Seitenleiste - Pastebin.com Code:
<?php /* Untermenü Seitenleiste * http://codex.wordpress.org/Function_Reference/wp_list_pages#List_whole_subpages */ if (!is_search() && !is_404()) : if (!$post->post_parent) { $ancestor_title = get_post($post); $ancestor_title = $ancestor_title->post_title; } if ($post->ancestors) { $ancestor_title = $post->ancestors; $ancestor_title = end($ancestor_title); $ancestor_title = get_the_title( $ancestor_title ); #debugVar($ancestor_title); } if (!$post->post_parent){ // will display the subpages of this top level page $args = array( 'title_li' => '', 'child_of' => $post->ID, 'echo' => 0, 'sort_column' => 'post_title' ); $children = wp_list_pages($args); } else { $ancestors = get_post_ancestors( $post->ID ); #debugVar($ancestors); /* debugVar($post); $ancestors2 = $post->ancestors; debugVar($ancestors2); */ $ancestors = end($ancestors); $args = array( 'title_li' => '', 'child_of' => $ancestors, 'echo' => 0, 'sort_column' => 'post_title' ); $children = wp_list_pages($args); } if ($children) { ?> <div class="ym-grid"> <div class="ym-gbox"> <h6 class="ym-vtitle"><?php echo $ancestor_title; ?></h6> <ul class="ym-vlist ym-clearfix"> <?php echo $children; ?> </ul> </div> </div> <?php } endif; ?> |
|
|||
![]()
Hi, Um die Post Vorfahren (auch Eltern) zu bekommen verwende einfach die get_post_ancestors () -Funktion. Diese Funktion nimmt ein einziges Argument, das entweder die Post-ID oder nach Objekt sein kann, und sendet die Vorfahren ID als Array.
PHP-Code:
PHP-Code:
PHP-Code:
MfG |
|
||||
![]() Zitat:
![]() |
![]() |
Stichwörter |
ancestor, parent, untermenü, wordpress |
Themen-Optionen | |
Ansicht | |
|
|
![]() |
||||
Thema | Autor | Forum | Antworten | Letzter Beitrag |
Standard Dropdown Menü in Wordpress Greyzed Theme | tfoal | CSS | 0 | 07.09.2011 12:53 |
Darstellungsproblem | flohpapa | CSS | 3 | 16.12.2009 09:55 |
Höhenproblem bei gruppiertem vertikalen div menü | Mathias3107 | CSS | 1 | 22.11.2009 14:42 |
CD-Sammlung zu verkaufen | Geronimo | Offtopic | 14 | 15.05.2009 22:35 |
Probleme beim ausdrucken | clumsy | CSS | 11 | 09.12.2008 13:42 |