Pregunta

Vamos a decir que tengo una página web sobre los diferentes tipos de vehículos. La estructura es un poco como esto:

-Home
-Cars (shows a submenu with a list of cars, ie Volvo 850, Porsche 911 )
 -Volvo 850 overview (the page you get when you click Volvo 850 on the Car page)
 -Volvo 850 tech spec (the three Volvo pages are shown as submenu links on any Volvo page)
 -Volvo 850 pictures
 -Porsche 911 overview
 -Porsche 911 tech spec
 -Porsche 911 pictures

¿Cuál es la mejor manera de hacer esto? Creo que lo que estoy preguntando es cómo automáticamente que la lista de páginas Coches los coches diferentes, y enlace a la página de información general y no a los demás. Y luego en las páginas individuales del coche, tener más submenús de descripción, especificación tecnología, y la página de imágenes.

Yo podría tener una estructura como esta:

-Cars (shows a submenu with a list of cars, ie Volvo 850, Porsche 911 )
 -Volvo 850
  -Volvo 850 overview (the page you get when you click Volvo 850 on the Car page)
  -Volvo 850 tech spec (the three Volvo pages are shown as submenu links on any Volvo page)
  -Volvo 850 pictures

.. pero no quiero que la página intermedia Volvo 850 para mostrar, porque no habría nada en él.

¿Fue útil?

Solución

Referencing the wp_list_pages function reference

You'll probably need to use the second structure you listed, with one change:

-Cars (shows a submenu with a list of cars, ie Volvo 850, Porsche 911 )
 -Volvo 850 overview (the page you get when you click Volvo 850 on the Car page)
  -Volvo 850 tech spec (the three Volvo pages are shown as submenu links on any Volvo page)
  -Volvo 850 pictures

I think the following may work, although it might show all descendants (rather than immediate children only):

<?php
  if($post->post_parent)
  $children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0");
  else
  $children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0");
  if ($children) { ?>
  <ul>
  <?php echo $children; ?>
  </ul>
  <?php } ?>

Your statement

And then on the individual car pages, have more sub-menus for overview, tech spec, and pictures page.

Seems contradictory to not wanting an 'intermediate' page, since you said you want the "overview" page to be what you land on when clicking on a car model on the cars page. If you just want all pages related to the Volvo 850 to have a listing of Volvo 850 pages (for instance, in the sidebar), you could possibly use this:

<?php 
// use wp_list_pages to display parent and all child pages all generations (a tree with parent)
$parent = 93;
$args=array(
  'child_of' => $parent
);
$pages = get_pages($args);  
if ($pages) {
  $pageids = array();
  foreach ($pages as $page) {
    $pageids[]= $page->ID;
  }

  $args=array(
    'title_li' => 'Tree of Parent Page ' . $parent,
    'include' =>  $parent . ',' . implode(",", $pageids)
  );
  wp_list_pages($args);
}
?>

Otros consejos

You asked a very similar and related question in "Same Custom Fields spanning several pages?" and I think your answer is really the same:

Licenciado bajo: CC-BY-SA con atribución
scroll top