Home › Forum › Plugin e temi di WP › Personalizzazione modelli
-
AutorePost
-
-
18 Giugno 2016 alle 7:56 #30915roberto2016Partecipante
Buongiorno a tutti.
Sono qui a chiedere un aiuto non per un problema specifico ma per una modifica agli standard di WP.
Dopo avere creato un nuovo modello (chiamiamolo pippo per comodità ) tra quelli proposti dalla versione gratuita del tema llorix-one-companion, ho necessità di aggiungere del codice che dovrà funzionare solo per i post che verranno inseriti sul modello “pippo” intercettando inoltre anche un valore passato in querystring.
La versione di wp è la 4.5.1.
Pur smanettando abbastanza in PHP non sono esperto del codice di wordpress e per questa ragione chiedo il vostro aiuto o comunque qualche indicazione.
Grazie
Roberto
-
18 Giugno 2016 alle 8:54 #120600wollyAmministratore del forum
cos’è un modello?
qual è la regola?
-
18 Giugno 2016 alle 10:58 #120601roberto2016Partecipante
Dunque, spero di avere compreso le domande
Quando in wordpress vado a comporre una pagina, sulla destra ho la possibilità di scegliere un modello di pagina..
La mia necessità è quella di fare in modo che quando viene creata una pagina contenente il modello di pagina da me creato (pippo) venga caricato del contenuto specifico pre-impostato e venga intercettato anche un valore passato in querystring.
Spero di essermi spiegato meglio e non avere commesso infrazioni alla policy del forum
Grazie
Roberto
-
18 Giugno 2016 alle 16:22 #120602wollyAmministratore del forum
un template di pagina di permette di fare quello che vuoi, probabilmente, da quello che ho capito, dovrai fare una wp_query personalizzata.
-
20 Giugno 2016 alle 9:41 #120604roberto2016Partecipante
Salve a tutti e grazie per chi ha provato a darmi una mano.
Non so se può essere utile ma in realtà ho risolto e quindi vi posto la procedura, per altro non difficile.
1) Per intercettare in querystring una variabile personalizzata è bastato aggiungere questo codice in wp-includes/query.php:
function add_query_vars_filter( $vars ){
$vars[] = “recid”;
return $vars;
}
add_filter( ‘query_vars’, ‘add_query_vars_filter’ );
2) nel template da me clonato ho aggiunto:
$recid = (get_query_var(‘recid’)) ? get_query_var(‘recid’) : 1;
ogni volta che la variabile $recid è != 1 faccio eseguire il codice che voglio io.
Buona giornata!
-
20 Giugno 2016 alle 11:07 #120605TittiModeratore
I file di WP non si modificano mai, e non solo perché ogni volta che aggiornerai perderai tutto.
Devi creare un child-theme, in cui avrai un file functions.php per quella e altre eventuali funzioni.
-
21 Giugno 2016 alle 7:44 #120607roberto2016Partecipante
Ops verissimo,
grazie per avermelo ricordato.
Ho dovuto far fronte a un’urgenza ma quanto prima creerò il tema child
buona giornata, WP guardato un po’ più da vicino non fa poi cosଠpaura
Roberto
-
-
AutorePost
- Devi essere connesso per rispondere a questo topic.