Home › Forum › Problemi Vari con WP › get_post_meta: cosa fa?
-
AutorePost
-
-
26 Dicembre 2011 alle 15:06 #20161smartmousePartecipante
Salve, ho scaricato un template che nell’index include la seguente parte di codice:
<?php
if (have_posts()) : while (have_posts()) : the_post();
$feature_img = get_post_meta($post->ID, 'Image', 'true');
?>
<div class="ins">
<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><img src="<?php echo $feature_img; ?>" alt="<?php echo $feature_desc; ?>" align="center" width="200" height="150" /> </a>Cosa fa esattamente “get_post_meta($post->ID, ‘Image’, ‘true’)” ?
Credo che dovrebbe visualizzare un’immagine accanto ad ogni post, ma non visualizza nulla, rimane infatti uno spazio vuoto. Se vado ad analizzare quello spazio è proprio il campo dedicato ad un’immagine…
Ma cosa va a prendere esattamente quella funzione? Quale immagine?
-
26 Dicembre 2011 alle 17:32 #91147SteveAglAmministratore del forum
quella definita nel campo personalizzato Image definito quando si scrive un articolo… leggere le istruzioni del tema aiuterebbe… ma direi che non lo hai fatto
-
26 Dicembre 2011 alle 18:30 #91149smartmousePartecipante
Il tema non ha istruzioni, inoltre non c’è nessun campo Image “quando si scrive un articolo”. Intendi quando si vuole creare un nuovo post? Se si, non ho un campo Image…
-
26 Dicembre 2011 alle 18:50 #91150SteveAglAmministratore del forum
Lo crei a mano nel blocco campi personalizzati.. li nella lista appaiono solo campi già definiti una prima volta…
PS. quale è il tema? Non credo non abbia nemmeno uno straccio di readme….
-
27 Dicembre 2011 alle 0:36 #91162smartmousePartecipante
Trovato!
Non lo vedevo perchè andava attivato in “Impostazioni schermo”.
In ogni caso non c’è il campo “Image” e l’ho creato io manualmente.
Comunque il tema è questo: http://www.w*rdpressthemesb**k.com/penda-forex
Dal momento che i post vengono creati da FeedWordpress, sai se c’è un modo per fargli creare automaticamente quel campo (e riempirlo anche)?
Edit: ho trovato il modo in FeedWordpress, solo che per ogni post dovrebbe mettere il link dell’immagine che trova nel post stesso tra i tag [img]e[/img] (sono post provenienti da un forum).
Sai se è possibile fare una cosa del genere?
-
27 Dicembre 2011 alle 9:34 #91164SteveAglAmministratore del forum
Solo con modifiche al plugin
-
27 Dicembre 2011 alle 15:42 #91177smartmousePartecipante
Nelle impostazioni di FeedWordpress, sotto Custom Post Settings, c’è la parte dedicata ai Custom Fields, con campi Key e Value da riempire.
Sotto c’è scritto:
Enter a text value, or a path to a data element from the syndicated item.
For data elements, you can use an XPath-like syntax wrapped in $( … ).
hello = the text value hello
$(author/email) = the contents of <author><email>…</email></author>
$(media:content/@url) = the contents of <media:content url=”…”>…</media:content>
Ho provato a scrivere “Image” nel campo key e nel campo value ho inserito “$(img)”, ma non ha funzionato.
Forse non c’è bisogno di effettuare modifiche al plugin, magari può funzionare usando la giusta sintassi…
Cosa ne pensi a questo punto?
-
27 Dicembre 2011 alle 16:00 #91179SteveAglAmministratore del forum
isogna vedere se i feed hanno le immagini e nel caso il loro formato… quindi per ogni feed se presente l’immagine andrà creata una regola specifica… ovvio che poi NON avrai la featured thumbnail ma un campo personalizzato da manipolare tu nel tue template.
-
27 Dicembre 2011 alle 17:54 #91187smartmousePartecipante
Si, i feed hanno le immagini, o meglio, contengono link ad immagini, e sono del formato jpg o png.
La regola da creare non può essere generalizzata per tutti i post che vengono raccolti da FWP?
-
27 Dicembre 2011 alle 18:37 #91191smartmousePartecipante
FWP funziona se nel campo key e value inserisco rispettivamente “Image” e un url fisso.
Occorrebbe un modo per inserire un url che varia a secondo di quello presente nel post… e se non c’è metto quello fisso.
Spero di essermi spiegato…
-
28 Dicembre 2011 alle 8:43 #91211SteveAglAmministratore del forum
Ha la sua sintassi per catturare contenuti dal feed, e non è possibile avere condizioni quindi se l’immagine c’0è la mette se non c’è non hai modo di metterla a meno che vi sia la stessa impostazione generale per tutti i feed… ma in ogni caso essendo feed diversi anel formato occorre creare una regola per cviascun feed…
-
28 Dicembre 2011 alle 11:02 #91233smartmousePartecipante
Sai se c’è una sintassi per catturare i tag simile a quella degli esempi sopra riportati?
Mi riferisco a:
hello = the text value hello
$(author/email) = the contents of <author><email>…</email></author>
$(media:content/@url) = the contents of <media:content url=”…”>…</media:content>
Almeno se l’immagine c’è la mette, se non c’è pazienza…
-
28 Dicembre 2011 alle 11:23 #91235SteveAglAmministratore del forum
dipende come è fatto l’elemento immagine.. ripeto.. l’esempio del plugin è chiaro.. se hai
<media:content url=”…”>…</media:content>
con
$(media:content/@url)
catturi la url…
-
28 Dicembre 2011 alle 13:20 #91237smartmousePartecipante
L’elemento immagine nei post è fatto in questo modo (presi da 3 post diversi):
<img src="http://www.sito1.com/img1.jpg" alt="" class="bbc_img" />
<img src="http://www.sito2.com/img2.png" alt="" class="bbc_img" />
<img class="bbc_img" src="http://www.sito3.com/img3.jpg" alt="" />Non c’è una sintassi dedicata a questo tipo url?
-
28 Dicembre 2011 alle 14:24 #91243SteveAglAmministratore del forum
No NON nei post nei feed.. se il feed non ha un elemento specifico xml che contiene l’immagine la vedo dura molto dura…
-
28 Dicembre 2011 alle 14:35 #91244zhenyaPartecipante
Un esempio di Feed RSS che contiene l’immagine della pagina, post o cosa altro sia
<rss version="2.0">
<channel>
<title>
Il titolo del Sito
</title>
<link>
la url della home page del sito
</link>
<description>
La descrizione del sito
</description>
<language>
IT
</language>
<item>
<title>
Il titolo di un post, pagina, o cosa sia
</title>
<description>
La descrizione presa dal post, pagina o cosa sia
</description>
<guid>
la url del post, pagina o cosa è
</guid>
<pubDate>
La data esempio: Sat, 24 Dec 2011 22:22:49 GMT
</pubDate>
<enclosure url="url della immagine o foto" type="image/Jpeg"/>
(qui cambia a secondo che sia jpg, jpeg, gif, png)
<link>
di nuovo la url del post, pagina o cosa è
</link>
</item>
e cosଠvia per tutto il file del tuo Feed RSS
@edit
Ovvio che il seguito riprende con
<item>
<title>
Quindi senza ripetere la parte alta delle testata di esempio.
-
28 Dicembre 2011 alle 15:01 #91245smartmousePartecipante
A me il feed è fatto in questo modo:
<rss version="2.0" xml:lang="it-IT">
<channel>
<title>NomeSito</title>
<link>http://www.sito.com/index.php</link>
<description><![CDATA[Informazioni aggiornate da NomeSito]]></description>
<item>
<title><![CDATA[Titolo topic 1]]></title>
<link>http://www.sito.com/index.php/topic,62.0.html</link>
<description>
<![CDATA[<img src="http://www.imageshack.com/123456.jpg" alt="" class="bbc_img" /><br /><img src="http://www.imageshack.com/12345.jpg" alt="" class="bbc_img" /><br /><br />Testo<br />Testo testo testo testo testo testo]]>
</description>
<comments>http://www.sito.com/index.php?action=post;topic=62.0</comments>
<category><![CDATA[NomeCategoria]]></category>
<pubDate>Tue, 27 Dec 2011 22:21:00 GMT</pubDate>
<guid>http://www.sito.com/index.php/topic,62.0.html</guid>
</item>C’è poco da fare in questo caso?
-
28 Dicembre 2011 alle 15:23 #91246zhenyaPartecipante
Il Feed posiziona l’immagine nella description invece che utilizzare uno specifico elemento:
<enclosure url="url della immagine o foto" type="image/Jpeg"/>
L’immagine “forse” apparirà con alcuni lettori di feed e non con altri.
-
28 Dicembre 2011 alle 15:36 #91248zhenyaPartecipante
@edit
Anzi di peggio! Con molta probabilità l’immagine la trovi all’interno del campo description in via del tutto casuale; questo poiché il programmatore lo ha scritto senza una “regola” per “filtrare” il contenuto.. Sarebbe a dire che quel RSS pesca quello che trova all’inizio del post o della pagina a prescindere da cosa sia.. Se cosà¬, andrebbe prima verificato meglio, dalle mie parti si direbbe che lo ha scritto un dilettante.
-
-
AutorePost
- Devi essere connesso per rispondere a questo topic.