Comment supprimer le lien "En savoir plus" de l'extrait de type de message personnalisé
-
-
Si vous vouliez une solution simpleet rapide,vouspouvieztoujours afficher: aucun le lien read_more sur ce CPT spécifiqueIf you wanted a quick and easy solution, you could always just display:none the read_more link on that specific CPT
- 0
- 2013-11-11
- Jonathan
-
Merci,j'y aipensé.Maisje préfère supprimer complètement le lien sipossible afin que Googlene suivepaset ne cachepas cespages spécifiques.Thanks, I thought about that. But I'd prefer to strip the link out completely if possible so that Google does not follow and cache these specific pages.
- 0
- 2013-11-11
- Evster
-
La réponse à cette questionest spécifique authèmeet non spécifique à WordPress car différentsthèmesincluent un code différentpour ajouter le lienen savoirplus http://codex.wordpress.org/Customizing_the_Read_More#Displaying_a_.22more.E2.80.A6.22_link_when_using_the_the_excerpt.28.29The answer to this question is theme specific and not specific to WordPress as different themes include different code for adding the read more link http://codex.wordpress.org/Customizing_the_Read_More#Displaying_a_.22more.E2.80.A6.22_link_when_using_the_the_excerpt.28.29
- 0
- 2014-05-22
- Brad Dalton
-
4 réponses
- votes
-
- 2014-01-01
Insérez le code suivant dans
functions.php
pour afficher "en savoirplus" surtous lestypes depublication saufcustom_post_type
.function excerpt_read_more_link($output) { global $post; if ($post->post_type != 'custom_post_type') { $output .= '<p><a href="'. get_permalink($post->ID) . '">read more</a></p>'; } return $output; } add_filter('the_excerpt', 'excerpt_read_more_link');
Put the following code in
functions.php
to show "read more" on all post types exceptcustom_post_type
.function excerpt_read_more_link($output) { global $post; if ($post->post_type != 'custom_post_type') { $output .= '<p><a href="'. get_permalink($post->ID) . '">read more</a></p>'; } return $output; } add_filter('the_excerpt', 'excerpt_read_more_link');
-
- 2019-12-08
J'ai corrigé ceproblèmeen ajoutant ce qui suit àfunctions.php
remove_filter('get_the_excerpt', 'wp_trim_excerpt');
Gracieuseté de Supprimerplus ou [...]texte de courtpost
I fixed this by adding the below to functions.php
remove_filter('get_the_excerpt', 'wp_trim_excerpt');
Courtesy of Remove more or [...] text from short post
-
- 2016-02-05
Une solution simpleest demettre le code suivant dans
style.css
:a.read-more { display:none; }
Ceci cible
<a class="read-more">
An easy solution is to put following code inside
style.css
:a.read-more { display:none; }
This targets
<a class="read-more">
-
Doit êtremarqué comme labonne réponse,car laméthodene fournitpas deparamètrepour la remplacer.Should be marked as the correct answer, because the method doesn't provide a parameter to override it.
- 0
- 2018-10-25
- sGambolati
-
- 2013-11-11
Et ça? Engros,c'est unmoyen depersonnaliser letexteen ajoutant unefonction de rappel aufichierfunctions.php. Jepense cependant que si vous renvoyez simplement unespace à laplace,il devrait le remplaceret ne rien afficher.
// Replaces the excerpt "more" text by a link function new_excerpt_more($more) { global $post; return ' '; } add_filter('excerpt_more', 'new_excerpt_more');
J'ai obtenu ceci de Le codex Wordpress
Modifier:
Cecin'apas ététesté,mais quefaire si vousfaites ceci:
// Replaces the excerpt "more" text by a link function new_excerpt_more($more) { global $post; if ($post->post_type == 'your-cpt') { return " "; } } add_filter('excerpt_more', 'new_excerpt_more');
Pour répéter,je n'aipastesté cela,maisje pourraispeut-être vousmettre sur labonne voie (c.-à-d. var_dump ($post)pour voir comment vouspouvez leplier à votre volonté àpartir de lafonctionnew_excerpt_more.
What about this? Basically it's a way to customize the text by adding a callback function to the functions.php file. I'm thinking, however, if you just return a space instead, then it should override it and not display anything.
// Replaces the excerpt "more" text by a link function new_excerpt_more($more) { global $post; return ' '; } add_filter('excerpt_more', 'new_excerpt_more');
I got this from The Wordpress codex
Edit:
This is untested, but what if you do this:
// Replaces the excerpt "more" text by a link function new_excerpt_more($more) { global $post; if ($post->post_type == 'your-cpt') { return " "; } } add_filter('excerpt_more', 'new_excerpt_more');
To reiterate, I haven't tested this, but may get you on the right track (i.e. var_dump($post) to see how you can bend it to your will from within the new_excerpt_more function.
-
Jepense que vous êtes sur labonne voie,mais coller ce codeexact dansmonfichierfunctions.php casseen faittout le site.Deplus,j'auraibesoin de lafonctionpour récupérer uniquement lesmessages dutype depublicationpersonnalisé 'staff-members'.I think you're on the right track, but pasting that exact code into my functions.php file actually breaks the entire site. Also, I'll need the function to grab only the posts from the 'staff-members' custom post type.
- 0
- 2013-11-11
- Evster
-
Mercipour l'aide!Il y aencore une sorte d'erreur dans la syntaxe qui supprimetout le siteet charge unepage vierge.Je vais voir sije peux le comprendre.Votre logique à ce sujet semble saine.Thanks for the help! There's still some kind of error in the syntax there that takes down the whole site and loads a blank page. I will see if I can figure it out. Your logic on this seems sound.
- 0
- 2013-11-11
- Evster
-
Vous devez retourner lafin de lafonction `$more`,sinontous les autrestypes depublicationmanqueront labalise/textemore.You need to return `$more` end of the function otherwise all other post type will miss the more tag/text.
- 0
- 2014-05-22
- Sisir
Y a-t-il unmoyen d'ajouter une sorte defiltre
pre_get_posts()
pour supprimer le lien "en savoirplus" qui apparaît à lafin dethe_excerpt()
pourun seultype depublicationpersonnalisé queje spécifie?Si oui,quelqu'unpeut-ilm'aider avec le code?J'ytravaille depuis unmoment,maisje n'ai abouti à rien.Toute aide seraitgrandement appréciée.Merci!