Home › Forum › Problemi Vari con WP › search form nel menu
-
AutorePost
-
-
31 Marzo 2013 alle 20:43 #24224elnPartecipante
Uso il template Twenty Eleven.
Come si fa a togliere il search form dall’header e spostarlo nel menu di navigazione principale, senza togliere la funzione ‘Testo della testata’?
Ho trovato alcuni post che fanno riferimento al functions.php ma non ho capito bene. Se provo a modificarlo va in crash.
L’unica cosa che sono riuscita a fare è modificare il css:
#branding #searchform {
position: absolute;
top: 295px;
right: 7.6%;
text-align: right;
}
Però se guardo il sito con una mobile device, essendo il tema responsive, ritorna nella posizione di default.
-
1 Aprile 2013 alle 3:19 #102616
-
2 Aprile 2013 alle 12:44 #102648elnPartecipante
Grazie infinite per la risposta, mi è stata necessaria.
Ho infatti modificato il foglio stile del template child in questo modo:
@media (max-width: 650px) {
/* Make sure the logo and search form don’t collide */
#branding #searchform {
top: 23.625em !important;
}
}
Ti chiedo però una cosa:
non c’è un modo per incorporare il search form all’interno del menù invece che agendo sul foglio stile?
Cosଠcome avviene quando dall’aspetto disabilito la funzione ‘Testo della testata’?
Lo chiedo perché ad esempio in un menù con diverse voci accade che con un mobile si vada poi a sovrapporre alle voci di menù.
Grazie ancora
-
6 Aprile 2013 alle 12:54 #102787elnPartecipante
Ho provato a modificare il file functions.php inserendo il seguente codice (nel template principale perché nel child non funziona).
Però adesso come faccio a togliere il search principale?
Inoltre non me lo allinea alle altre voci di menù e non so quale classe del css modificare.
function add_search_to_wp_menu ( $items, $args ) {
if( ‘primary’ === $args -> theme_location ) {
$items .= ‘<li class=”menu-item menu-item-search”>’;
$items .= ‘<form method=”get” class=”menu-search-form” action=”‘ . get_bloginfo(‘home’) . ‘/”><p><input class=”text_input” type=”text” value=”ricerca” name=”s” id=”s” onfocus=”if (this.value == ‘Enter Text & Click to Search’) {this.value = ”;}” onblur=”if (this.value == ”) {this.value = ‘ricerca’;}” /><input type=”submit” class=”my-wp-search” id=”searchsubmit” value=”search” /></p></form>’;
$items .= ”;
}
return $items;
}
add_filter(‘wp_nav_menu_items’,’add_search_to_wp_menu’,10,2);
-
6 Aprile 2013 alle 16:08 #102790elmaniseroPartecipante
Rimetti le cose com’erano prima.
Apri style.css e header.php entrambi originali.
Sostituisci la riga 640 del css con questo #branding #searchform { margin: 5px 5px 0 0; position: inherit;}
Sostituisci la riga 134 del header con questa <?php wp_nav_menu( array( ‘theme_location’ => ‘primary’ ) ); ?><?php get_search_form(); ?>
Cancella tutto dalla riga 115 alla 126 compresi, sempre nel header.
Ovviamente tutto questo lo dovrai mettere nel child.
-
7 Aprile 2013 alle 13:59 #102794elnPartecipante
Perfetto! Grazie mille! Ho fatto le modifiche che mi hai indicato risalendo alle righe giuste del codice da modificare perché avevo già fatto altre personalizzazioni al template child e non potevo cancellare tutto.
Ed era esattamente quello che volevo. Sei stato molto gentile.
Ti chiedo una cosa, è corretto inserire solo le righe di codice che cambiano rispetto al tema principale? Io sto procedendo cosଠperché avevo capito che altrimenti ci fosse una ridondanza di codice ma dalle tue indicazioni mi sembra che nn sia importante.
Poi vorrei chiederti altre cose che riguardano la personalizzazione di questo template ma apro un altro post perché a questo punto è un altro argomento.
Spero potrai aiutarmi ancora!
-
7 Aprile 2013 alle 14:56 #102795elmaniseroPartecipante
avevo capito che altrimenti ci fosse una ridondanza di codice
Falso.
Tranne il functions.php e lo style.css che è già richiamato per modificare un file basta copiarlo, incollarlo nel child e modificarlo.
-
7 Aprile 2013 alle 15:02 #102796elnPartecipante
Ah ok! Ho capito. Grazie!
-
-
AutorePost
- Devi essere connesso per rispondere a questo topic.