Home › Forum › Plugin e temi di WP › Come evitare che l'immagine inserita come anteprima compaia anche nel post
-
AutorePost
-
-
2 Luglio 2016 alle 8:17 #30939MagiusPartecipante
Salve,
premetto di avere la versione 4.5.3–it_IT di wordpress e windows come server.
Utilizzo baskerville come tema, personalizzato. Questa la mia pagina: http://www.christianlamberti.com
Il mio problema è come fare a inserire un’immagine come anteprima dell’articolo senza che, una volta aperto l’articolo stesso, questa vi compaia. In un’altra discussione, con un tema diverso dal mio, ho letto di dover modificare il file “single.php”. Per la precisione veniva spiegato di rimuovere alcune righe contenenti la voce “thumbnail”. Ebbene, ho fatto alcune prove (sebbene le righe del file di quel tema non corrispondano alle mie) ma in un caso gli articoli non mi venivano neanche aperti (il link mi dava errore), eliminando altre righe invece non è cambiato nulla.
Sostanzialmente presumo che la porzione del file “single.php” da modificare sia la seguente:
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div id=”post-<?php the_ID(); ?>” <?php post_class(); ?>>
<?php if ($format == ‘quote’ || $format == ‘link’ || $format == ‘audio’ || $format == ‘status’ || $format == ‘chat’) : ?>
<?php if ( has_post_thumbnail() ) : ?>
<div class=”featured-media”>
<?php the_post_thumbnail(‘post-image’); ?>
<?php if ( !empty(get_post(get_post_thumbnail_id())->post_excerpt) ) : ?>
<div class=”media-caption-container”>
<p class=”media-caption”><?php echo get_post(get_post_thumbnail_id())->post_excerpt; ?></p>
</div>
<?php endif; ?>
Grazie in anticipo per la disponibilità .
-
2 Luglio 2016 alle 16:13 #120662
-
3 Luglio 2016 alle 11:03 #120665MagiusPartecipante
Grazie per l’aiuto, mi è stato utile per risolvere il problema.
Tuttavia c’è una precisazione da fare.
Il codice presente nel link che mi avete inviato, ovvero questo:
.single .featured-media {
display: none;
}
Non va inserito alla fine del file style.css, come riportato nella discussione del link, ma in un punto preciso. Per l’esattezza nella sezione /* Featured media */. Ecco come:
/* Featured media
*/.featured-media a,
.featured-media img,
.featured-media iframe { display: block; }
.single .featured-media { display: none; }
In questo modo il problema è risolto.
Spero di essere utile anche ad altri con la mia stessa problematica.
Grazie ancora a voi dell’assistenza, gentilissimi.
-
3 Luglio 2016 alle 18:35 #120666TittiModeratore
No, il tema originale non si tocca mai. Devi creare un child-theme, e inserire lଠtutte le modifiche, come diciamo sempre, e come viene giustamente detto anche in quella discussione alla prima risposta, che evidentemente non hai letto, o hai ignorato.
In alternativa, se il tema prevede uno spazio Custom CSS, puoi inserire lଠtutte le modifiche CSS.
Un’altra eventualità è usare un plugin, ma è cosa che personalmente non consiglio, per evitare di aggiungere qualcosa di cui si può fare a meno.
La soluzione migliore è il child theme.
Se finora hai fatto tutte le tue modifiche sul tema originale hai sbagliato perché quando dovrai aggiornarlo le perderai. Bisogna sempre usare le versioni originali, anche dei plugin, specie se non si è esperti.
-
4 Luglio 2016 alle 19:41 #120667MagiusPartecipante
Questa purtroppo è una procedura che non ho seguito.
Quando mi sono fatto aiutare da un amico per creare inizialmente il sito non mi ha consigliato di impostare un child-theme.
Posso rimediare ora senza perdere tutte le modifiche effettuate?
-
5 Luglio 2016 alle 9:39 #120668TittiModeratore
Le modifiche le dovrai rifare sul child-theme, dopo che avrai constatato il suo funzionamento.
La versione del tema modificato che stai usando ora dovrai cancellarla, e al suo posto installare il tema originale.
-
-
AutorePost
- Devi essere connesso per rispondere a questo topic.