Supprimer plus ou [...] texte d'un court message
6 réponses
- votes
-
- 2014-09-21
Le codexest votre amiet devrait être votrepremier arrêt :-)
Le
[...]
est ajoutéparthe_excerpt()
.Ilexiste unfiltrefourni appelé lefiltreexcerpt_more
quiest spécifiquementincluspourpersonnaliser letexteen savoirplus après l'extraitPour supprimer le
[...]
après letexte de l'extrait,vouspouvezfaire ce qui suitfunction new_excerpt_more( $more ) { return ''; } add_filter('excerpt_more', 'new_excerpt_more');
The codex is your friend and should be your first stop :-)
The
[...]
is added bythe_excerpt()
. There is a filter supplied called theexcerpt_more
filter that is specifically included to customize the read more text after the excerptTo remove the
[...]
after the excerpt text, you can do the followingfunction new_excerpt_more( $more ) { return ''; } add_filter('excerpt_more', 'new_excerpt_more');
-
Mercipour votre réponse votre codefonctionnebien pour supprimer [...],mais le shortpostesttoujours limitéet lemot coupé après quelques caractères Je veux agirnormalement (tout avant de lireplus debalises surmon courtpost)thanks for reply your code is work well for remove [...] , but still the shortpost are limited and word cut after some characters I want act normal ( everything before read more tag show on my short post )
- 0
- 2014-09-21
- Arioman
-
une autre questionjustepour les curieux,commentpuis-je changer le [...]pour quelque chose d'autreparexemple [plus ...]another Question just for curious , how can i change the [...] to some thing else for example [ more ... ]
- 0
- 2014-09-21
- Arioman
-
Vous devriez lire [cet article] (http://wordpress.stackexchange.com/a/141136/31545).J'aitout couvert dans cepost.J'espère que cela aide :-).N'oubliezpas d'accepterma réponse sielle a aidé à résoudre votreproblème.You should read [this post](http://wordpress.stackexchange.com/a/141136/31545). I've covered about everything in that post. Hope it helps :-). Remeber to accept my answer if it helped solving your issue.
- 0
- 2014-09-21
- Pieter Goosen
-
celane semble supprimer que le lienen savoirplus.Le «[...]»esttoujours là.this seems to only remove the read more link. The `[...]` is still there.
- 0
- 2017-09-21
- Jules
-
- 2019-03-23
Comme d'autres l'ont déjà souligné,utiliser le crochet defiltre
excerpt_more
est labonne solution.Je voulaisjuste ajouter que vousn'avezpas à écrire unefonction qui renvoie une chaîne vide.WordPress a quelquesfonctionsintégréespour renvoyer vrai,faux,zéro,nul,chaîne vide outableau vide.
Dans ce cas,nous avonsbesoin de __return_empty_string ()
Vouspouvez ajouter ce code à votreplugin ou auxfunctions.php de votrethème:
<?php // This will add a filter on `excerpt_more` that returns an empty string. add_filter( 'excerpt_more', '__return_empty_string' ); ?>
As others have already pointed out, using the
excerpt_more
filter hook is the right way to go.Just wanted to add that you don't have to write a function that returns an empty string. WordPress has a few built in functions to return true, false, zero, null, empty string or empty array.
In this case we need __return_empty_string()
You can add this code to your plugin or to your theme's functions.php:
<?php // This will add a filter on `excerpt_more` that returns an empty string. add_filter( 'excerpt_more', '__return_empty_string' ); ?>
-
- 2017-02-21
c'est dutravailpourmoi!
function change_excerpt( $text ) { $pos = strrpos( $text, '['); if ($pos === false) { return $text; } return rtrim (substr($text, 0, $pos) ); } add_filter('get_the_excerpt', 'change_excerpt');
that is work for me !
function change_excerpt( $text ) { $pos = strrpos( $text, '['); if ($pos === false) { return $text; } return rtrim (substr($text, 0, $pos) ); } add_filter('get_the_excerpt', 'change_excerpt');
-
- 2019-06-13
'excerpt_more'est un hook WordPress.Il renvoie l'extrait de contenu. Pour supprimer le [...] après letexte de l'extrait,vouspouvez renvoyer leblanc comme ci-dessous ou vosexigencespersonnalisées.Utilisez ce code surfunction.php
function custom_excerpt_more( $excerpt ) { return ''; } add_filter( 'excerpt_more', 'custom_excerpt_more' );
'excerpt_more' is a WordPress hook. It returns the content excerpt. To remove the [...] after the excerpt text, you can return blank like below or your custom requirements. Use this code on function.php
function custom_excerpt_more( $excerpt ) { return ''; } add_filter( 'excerpt_more', 'custom_excerpt_more' );
-
- 2014-09-21
Vous devriez l'ajouter à votre
functions.php
function custom_excerpt_more( $more ) { return '';//you can change this to whatever you want } add_filter( 'excerpt_more', 'custom_excerpt_more' );
Deplus,l'utilisation de
the_excerpt
présente l'avantage denettoyer automatiquement le contenuet de supprimertoutes lesimageset autresbalises HTML.Vouspouvez en savoirplusici
Si vous souhaitez égalementmodifier la longueur de l'extrait,vouspouvez ajouter cetextrait à votre
functions.php
:function custom_excerpt_length( $length ) { return 20;//change the number for the length you want } add_filter( 'excerpt_length', 'custom_excerpt_length', 999 );
Pouren savoirplus, cliquezici
You should add this to your
functions.php
function custom_excerpt_more( $more ) { return '';//you can change this to whatever you want } add_filter( 'excerpt_more', 'custom_excerpt_more' );
Also, using
the_excerpt
has the advantage that automatically cleans the content, and deletes all images, and other HTML tags.You can read more here
If you also want to modify the length of the excerpt, you can add this snippet to your
functions.php
:function custom_excerpt_length( $length ) { return 20;//change the number for the length you want } add_filter( 'excerpt_length', 'custom_excerpt_length', 999 );
You can read more about this here
-
Quelles versions ciblez-vous,c'est-à-dire avant la 2.9 :-)Which versions are you targeting, that is pre 2.9 :-)
- 0
- 2014-09-21
- Pieter Goosen
-
@PieterGoosen,je suppose que c'est lemauvais.@PieterGoosen, I guess the wrong one.
- 0
- 2014-09-21
- Tomás Cot
-
votre codefonctionnebien avec le changement de longueurmais quandje le supprime,[...]il seramoche quand unepartie duparagraphe semblemanquante ce seragénial si d'unemanière ou d'une autre détecte unparagraphe à laplace de la longueur !! //un autreproblème avec l'extrait concerne les codes courts,je nepeuxpasmettre de lecteur vidéo ou de diaporama surmon courtmessageyour code work well with changing length but when i remove [...] it will be ugly when a part of paragraph looks missing it will be great if somehow detect a paragraph instead lenght !! // another problem with excerpt is about shortcodes , i cant put video player or slideshow to my short post
- 0
- 2014-09-21
- Arioman
-
@Arioman,vouspouvez changer le [...] avec un lien qui dit "Continuez à lire",ou ce que vous voulez.Maintenant,si vous voulez avoir des shortcodesfonctionnels,`the_excerpt`n'estpas ce que vous recherchez,vous devriez l'ajouter à la question,car les réponses changeront.@Arioman, you can change the [...] with a link that says "Keep reading", or whatever you want. Now, if you want to have working shortcodes, `the_excerpt` isn't what you are looking for, you should add that to the question, as the answers will change.
- 0
- 2014-09-21
- Tomás Cot
-
@ TomásCotmercipour ceguidefantastique.jemetstous les codes (code complet) dansmonfunction.phpet supprime $ wpse_excerpt=strip_tags ($ wpse_excerpt,wpse_allowedtags ());pour acceptertoutes lesbalises,j'utilise stream videoplayerpourinsérer une vidéoet ilgénère des shortcodes comme: [streamflv=http://****/clip/shad.m4vembed=false share=false width=640 height=360 dock=true controlbar=overbandwidth=high autostart=false responsive=16: 9/]maisje reçoistoujours untexte: * Vidéo:ma vidéo au lieu demontrermon lecteur vidéoen shortpost oùestmonproblème??@TomásCot thanks for this fantastic guide . i put all codes (complete code) in my function.php and remove $wpse_excerpt = strip_tags($wpse_excerpt, wpse_allowedtags()); for accept all tags i use stream video player for insert video and it generates shortcodes like : [stream flv=http://****/clip/shad.m4v embed=false share=false width=640 height=360 dock=true controlbar=over bandwidth=high autostart=false responsive=16:9 /] but still i get a text : *Video: my video instead of showing my video player in shortpost where is my problem ??
- 0
- 2014-09-22
- Arioman
-
Pouvez-vous ajouter le code à la question?Can you add the cod eto the question?
- 0
- 2014-09-22
- Tomás Cot
-
- 2016-06-16
Essayez de créer unenouvellefonction dans votre
functions.php
:function custom_excerpt() { $text=preg_replace( "/\\[…\\]/",'place here whatever you want to replace',get_the_excerpt()); echo '<p>'.$text.'</p>'; }
Ensuite,utilisez lanouvellefonction sur votrepage.
Try to create a new function in your
functions.php
:function custom_excerpt() { $text=preg_replace( "/\\[…\\]/",'place here whatever you want to replace',get_the_excerpt()); echo '<p>'.$text.'</p>'; }
Then use the new function on your page.
J'utilise unthème qui a une limite de caractèrespour les articles courtset [...] à afficher à lafin de la limite de caractères.
Je veux supprimer ceci,doncje recherche
the_excerpt();
et le remplaceparthe_content();
Leproblèmeest résolu avec le contenunormalmaisil y atoujours unproblème avec letype depublication d'imageet il y a
<?php the_excerpt(); ?>
que lorsqueje change cela,monpost court agit comme unpost completet cen'estpas lié à la longueur dupost.J'essaye d'ouvrirtous lesfichiers PHP dans lethèmeet de chercher desmots clés comme: limite,longueur,extraitpourtrouver où setrouve le code qui définit la longueur du shortpostmême chercher "[...]" danstous lesfichierset languemaisje ne saispas d'où cela vient.
Maistout ce queje trouveest une ligne de code dans
function.php
Et quandj'augmente 18,rienne change!
Quel code dois-je rechercher?