Home › Forum › Problemi Vari con WP › Come mostrare una lista contenente i campo personalizzati dei post?
-
AutorePost
-
-
28 Ottobre 2011 alle 21:57 #19583Profeta11Partecipante
Avrei la necessità di mostrare in home page (o in un altra pagina) una sorta di tabella o di lista, che contenga su ogni riga il titolo del post e di seguito i campi personalizzati, come si può realizzare questa cosa?
Per meglio spiegare, io voglio creare un articolo con titolo “Libro n°1” che avrà campi personalizzati come “numero pagine” “autore” “casa editrice” (sono esempi ovviamente) e vorrei poter fare una lista di diciamo gli ultimi 15 articoli in modo tale che mi vengano mostrati come
Libro n°6 100 Pagine autore casaeditrice
Libro n°5 100 Pagine autore casaeditrice
Libro n°4 100 Pagine autore casaeditrice
Libro n°3 100 Pagine autore casaeditrice
Libro n°2 100 Pagine autore casaeditrice
Libro n°1 100 Pagine autore casaeditrice
come posso fare a richiamare i campi personalizzati in modo tale che siano visualizzati in questo modo?
-
29 Ottobre 2011 alle 1:22 #89357EmmePartecipante
La forma e lo stile con cui far apparire gli ultimi post li scegli tu, sia che si tratti di uno stile tradizionale (titolo, articolo, categoria, tags, etc) sia che si tratti di una forma abbreviata (titolo, campi personalizzati). Devi comunque mettere mano al loop (in index.php o loop.php). Come? Difficile spiegarlo in due righe, ti consiglio la letture di questa guida. In particolare loop e pagina principale.
Per quanto riguarda un uso approfondito dei campi personalizzati, trovi moltissime guide su Google (cerca semplicemente “campi personalizzati”).
Il resto è solo una questione di CSS. Vierne da sé che devi conoscere CSS e HTML come minimo, diversamente non ti resta che trovare un tema già impostato per quel che vuoi fare tu.
-
29 Ottobre 2011 alle 10:17 #89360Profeta11Partecipante
In realtà mi sono già documentato, ed ho trovato che la sintassi per richiamare i campi è questa
get_post_meta($post_id, $key, $single);
però in questo modo richiamo solo il campo di un post che indico io dall'id.
Quello di cui avrei bisogno io è, una volta aver impostato stile e tutto quanto, che mi vengano visualizzati i campi degli ultimi 15 articoli ad esempio, senza dover andare a rimettere a mano gli id ogni volta che aggiungo un articolo.
Di questo non ho trovato traccia da nessuna parte.
Esiste quindi un modo per indicare gli ultimi 15 id in ordine dal più recente al più vecchio? -
29 Ottobre 2011 alle 11:54 #89364EnricoWPPartecipante
In alternativa, potresti utilizzare semplicemente i tag. Per fare un esempio, basta creare i tag, “Roberto Saviano”, “252 pagine”, “Mondadori”. Imposti il tema in modo da richiamare il titolo del libro e subito dopo i tag, con questo risultato:
La bellezza e l’inferno
Roberto Saviano – 252 pagine – Mondadori
L’unico aspetto negativo è che andresti a creare un’enormità di tag, ma a livello pratico non è un problema, per quanto tecnicamente sia una soluzione un po’ grezza. In compenso, essendo i tag cliccabili, possono garantire un livello di ricerca dei contenuti ottimale: leggo “Saviano”, ci clicco sopra e si apre una lista con tutti i suoi libri, automaticamente e senza dover modificare nulla in termini di codice (non so se sia fattibile anche con i custom fields, ammetto di non averli mai utilizzati se non per richiamare le classiche immagini personalizzate).
-
29 Ottobre 2011 alle 16:53 #89368Albert EinsteinPartecipante
Io ti proporrei un bel plug-in semplice semplice: w4 post list, provalo e dimmi se fa al caso tuo!
-
29 Ottobre 2011 alle 17:25 #89371TittiModeratore
w4 post list, provalo e dimmi se fa al caso tuo!
w4 post list è adatto per fare una pagina archivio con i titoli, categorie… ma non mostra i custom field
w4 Content tabset, semmai.
-
-
AutorePost
- Devi essere connesso per rispondere a questo topic.