Home › Forum › Problemi Vari con WP › immagini linkate al post anche dopo cancellazione
-
AutorePost
-
-
25 Settembre 2012 alle 13:00 #22656zocPartecipante
Ciao a tutti,
sono un pò in crisi e mi servirebbe una mano.
Non capisco perchè quando cancello dal mio articolo delle immagini precedentemente inserite, se poi vado nel pannello “media” le mie immagini sono ancora collegate al mio post.
Infatti se faccio un get_post degli attachment mi vengono restituite tutte le immagini (anche se cancellate dal corpo del mio articolo).
$args = array(
'post_type' => 'attachment',
'post_mime_type' => 'image',
'numberposts' => -1,
'post_status' => null,
'post_parent' => $post->ID
);
$attachments = get_posts($args);
if ($attachments) {
foreach ($attachments as $attachment) {
$img_id[] = $attachment->ID;
}
}
grazie in anticipo!
-
25 Settembre 2012 alle 16:38 #97681wollyAmministratore del forum
come le hai cancellate?
Se le hai solo tolte dal post non le hai cancellate, devi entrare nella gestione media dle post o in quella generale e cancellarle da li.
-
26 Settembre 2012 alle 6:31 #97685zocPartecipante
Ciao Wolly,
e grazie per la risposta.
Sono entrato nel pannello media e sono andato a modificare l’immagine, ma non ho trovato nulla che mi permetta di scollegare l’immagine al post.
Inoltre ho visto che se l’immagine è inserita in più post, nel pannello media è segnalata come “collegata” a un solo post.
Infatti nel database ho visto che i post type “attachment” hanno un valore per post_parent… e se la stessa immagine è usata per più articoli, non vengono aggiunte relazioni nel database, ma solo il codice html dell’immagine all’interno dei vari articoli.
La cosa che crea problemi con la query he ho scritto sopra è che se si cancella un’immagine dal proprio articolo questo non viene aggiornato nel record del attachment.
Quindi meglio cambiare strada e mi chiedo se è possibile, in recupero dati ( the_content()), intervenire sui tag img e levare le dimensioni e aggiungergli una classe.
Grazie mille!
-
-
AutorePost
- Devi essere connesso per rispondere a questo topic.