Home › Forum › Problemi Vari con WP › is_page e tag condizionali – aiuto correzione codice
-
AutorePost
-
-
26 Settembre 2012 alle 22:33 #22672warholaPartecipante
Ciao!
premetto che so che ci sono già post che riguardano l’uso di tag condizionali e di array e la funzione is_page, ma non conosco proprio il php, purtroppo, e non sono capace di adattare le soluzioni proposte a quei problemi per risolvere questo mio.
Se perfavore qualcuno può aiutarmi correggendomi il codice che propongo ne sarei grato:
In pratica sul mio sito http://www.ripamonticomo.it/wp/ devo poter inserire dei menu di secondo livello a destra quando ci si trova in una delle pagine del menu principale orizzontale (esclusa home ovviamente) o nelle sue sottopagine.
La funzione che è presente ora non va bene perchè dice semplicemente che il menu di secondo livello appare in caso ci si trovi in una pagina che possiede delle sottopagine, ma quando sono in una sottopagina il menu quindi non si vede più.
la funzione è questa:
<?php if (is_page()) {
$children = wp_list_pages('title_li=&depth=1&child_of='.$post->ID.'&echo=0');
if ($children) { ?>
<ul class="gerarchia">
<?php echo $children; ?>
<?php }
} ?>
Prendendo come esempio la pagina DOCENTI (ID 7) mi servirebbe una funzione che dica che in caso ci si trovi nella pagina DOCENTI o nelle sue sottopagine, venga mostrato a destra un menu con le pagine figlie di 7.
Cercando tra qui e altri siti in internet sono arrivato a una funzione di questo tipo:
<?php if (is_page(array(7,1079,1376,1073,1071,1077,1075,1069,1081)) {
?>
<?php
wp_list_pages('sort_column=menu_order&child_of=7&title_li='); ?>
<?php
} ?>
che però non funziona..
7 è l’ID della pagina DOCENTI, e gli altri ID sono le sue 8 pagine figlie.
Chi potrebbe aiutarmi per favore?
Grazie
Giancarlo
-
27 Settembre 2012 alle 8:27 #97707wollyAmministratore del forum
Comincia cosà¬:
<?php if (is_page(array(7,1079,1376,1073,1071,1077,1075,1069,1081)) {
?>
<?php echo 'funziona'; ?>
<?php } ?>
e vediamo di capire dove stà l'inghippo. -
28 Settembre 2012 alle 18:56 #97759warholaPartecipante
ho messo il codice php esattamente al posto di quello che c’è ora ma mi sparisce tutta la rightsidebar, e anche la barra di wordpress in alto…
non credo sia un problema di chiusura tag, copio tutto il codice iniziale di rightsidebar.php com’è ora, cosଠabbiamo tutte le carte in tavola
<div id="rightsidebar" class="column">
<!-- MENU DI SECONDO LIVELLO -->
<?php if (is_page()) {
$children = wp_list_pages('title_li=&depth=1&child_of='.$post->ID.'&echo=0');
if ($children) { ?>
<ul class="gerarchia">
<?php echo $children; ?>
<?php }
} ?>
<!--FINE MENU DI SECONDO LIVELLO -->
<?php if ( function_exists('dynamic_sidebar') && dynamic_sidebar(2) ) >
<?php endif; ?>
-
-
AutorePost
- Devi essere connesso per rispondere a questo topic.