Home › Forum › Amministrazione WP › Visualizzare solo le pagine figlie dell’attuale
-
AutorePost
-
-
3 Dicembre 2006 alle 18:45 #2675gorkaPartecipante
Nel blog che sto preparando ho molte pagine da inserire.
La struttura è tipo questa:
– Pagina Radice
— Pagina 1
— Pagina A
— Pagina B
— Pagina 2
— Pagina C
— Pagina D
— Pagina E
ecc….
Il problema è che quando clicco su “Pagina Radice” nel menu in alto e leggo il contenuto di quella pagina sulla sinistra nel menu “More Pages” mi compaiono tutte le sottopagine (1, A, B, 2, C,D, E). Io invece vorrei visualizzare solo le pagine figlie della corrente, cioè se sono su “Pagina Radice” devo avere nel menu la 1 e la 2, se mi trovo su “Pagina 1” nel menu dovrei avere A e B.
Non so se sono stato chiaro, spero di si.
-
3 Dicembre 2006 alle 19:10 #41976wollyAmministratore del forum
cerca nel wiki e nel forum se ne è parlato decine di volte.
ciao
-
4 Dicembre 2006 alle 17:56 #42010gorkaPartecipante
Ho capito che devo utilizzare il parametro child_of della funziona wp_list_pages
Però come faccio a sapere l’ID della pagina attuale?
-
4 Dicembre 2006 alle 19:54 #42015wollyAmministratore del forum
Menu gestione, pagine e leggi l’ID delle pagine.
ciao
wolly
-
4 Dicembre 2006 alle 21:33 #42019ondapiPartecipante
io uso questo lo ho copiato da kubrick ma non so se funziona su tutti i temi
<!--inizio modulo pagina sottopagina -->
<?php global $notfound; ?>
<?php /* Creates a menu for pages beneath the level of the current page */
if (is_page() and ($notfound != '1')) {
$current_page = $post->ID;
while($current_page) {
$page_query = $wpdb->get_row("SELECT ID, post_title, post_status, post_parent FROM $wpdb->posts WHERE ID = '$current_page'");
$current_page = $page_query->post_parent;
}
$parent_id = $page_query->ID;
$parent_title = $page_query->post_title;
if ($wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_parent = '$parent_id' AND post_status != 'attachment'")) { ?>
<div class="sb-pagemenu"><h2> elenco sottopagine <?php echo $parent_title; ?>:</h2>
<ul><?php wp_list_pages('sort_column=menu_order&title_li=&child_of='. $parent_id); ?> </ul>
<?php if ($parent_id != $post->ID) { ?>
<a href="<?php echo get_permalink($parent_id); ?>"><br/><br/>ritorna a <?php echo $parent_title; ?></a>
<?php } ?>
</div>
<?php } } ?>
<!--fine modulo pagina sottopagina -->
-
19 Febbraio 2012 alle 1:24 #93447pittinicchioPartecipante
Io ricevo il titolo sottopagine di “nome pagina” anche quando non ci sono sottopagine!
Ora devo vedere di uscirne, intanto grazie (seppur in ritardo) a chi facilità l’orientamento con questi stralci di codice.
Grazie
-
-
AutorePost
- Devi essere connesso per rispondere a questo topic.