
Ci sono più modi per poter cambiare la lunghezza dell’excerpt (riassunto) di un articolo su WordPress.
Ho collezionato in questo post i metodi funzionanti per cambiare il valore di default che è impostato su (55), a qualsiasi lunghezza.
Soluzione 1 – Cambiare la lunghezza dell’excerpt da “wp-includes”
PRO: Facile e veloce.
CONTRO: Questa modificha verrà applicata a tutte le categorie, agli archivi ed anche all’homepage del blog.
Fonte: It’s Called Web Design
Apri il file “wp-includes/formatting.php” alla linea 1333 (linea 853 per le versione precedenti alla 2.7).
Cambia il valore “55” in quello che preferisci.
Soluzione 2 – Cambiare la lunghezza dell’excerpt utilizzando i filtri in “functions.php”
PRO: Puoi impostare valori di lunghezza diversa in ogni categoria, archivio, singole pagine, etc.
CONTRO: Richiesta una skill minima in PHP
Fonte: WordPress Codex
Puoi cambiare la lunghezza dell’excerpt di wordpress utilizzando il filtro excerpt_length . Inserisci questo codice nel file “wp-content/themes/THEME_NAME/functions.php” :
1 2 3 4 5 6 |
<?php function new_excerpt_length($length) { return 20; } add_filter('excerpt_length', 'new_excerpt_length'); ?> |
Soluzione 3 – Cambiare l’excerpt utilizzando l’ “Excerpt Plugin”
PRO: Facile da usare.
CONTRO: Richiesta una skill minima in PHP
Fonte: Download from guff.szub.net
Configura la lunghezza dell’excerpt utilizzando il plugin “Excerpt Reloaded”. Devi essere in grado di modificare il tema per poter utilizzare questo plugin.
Parametri:
- excerpt_length (integer) – Numero delle parole da visualizzare. Il parametro di default è120.
- allowedtags (string) – Definisce i tag HTML. Il parametro di default è ‘<a>’.
- filter_type (string) – Definisce con WP deve filtrare il contenuto. Le opzioni sono basate sui tag: ‘content’, ‘content_rss’, ‘excerpt’, ‘excerpt_rss’. Settare su ‘none’ per visualizzare il contenuto raw. Il parametro di default è ‘excerpt’.
- use_more_link (boolean) – Visualizza il link “more” (TRUE) o (FALSE). Il parametro di default è su TRUE.
- more_link_text (string) – Definisce il nome utilizzato sul link. Il parametro di default è ‘(more…)’.
- Other functions: force_more_link (boolean) – fakeit (integer) – fix_tags (boolean).
Buon codice a voi tutti! 🙂
[…] The manual Excerpt in WordPress Ultimate Guide to WordPress SEO – META Descriptions How to use the Excerpt field from WordPress for SEO WordPress meta description using post excerpt, category description and post ID The WordPress excerpt: What, why, how, tips and plugins Using WordPress Excerpts Change excerpt length in wordpress […]
Thanks, been searching all day for something like this (solution 2). But I couldn’t get it to work properly before I included the tricks from this site:
http://www.webwalkersolutions.com/how-to-fix-wordpress-fatal-error-call-to-undefined-function-the_content_limit-in
[…] The manual Excerpt in WordPress Ultimate Guide to WordPress SEO – META Descriptions How to use the Excerpt field from WordPress for SEO WordPress meta description using post excerpt, category description and post ID The WordPress excerpt: What, why, how, tips and plugins Using WordPress Excerpts Change excerpt length in wordpress […]