-
AuthorPosts
-
January 19, 2017 at 7:08 pm #736029
Hi Guys,
Our client wants the excerpt cut off after exactly the amount of characters specified in the magazine.php, not after whoile words. Is there a way to do this?
Thanks,
MaxJanuary 19, 2017 at 7:48 pm #736048Hi Max!
Please add following code to Functions.php file in Appearance > Editor
add_filter('avf_magazine_excerpt_length','avf_magazine_excerpt_new_lenght', 10, 1); function avf_magazine_excerpt_new_lenght($excerpt) { $excerpt = 100; return $excerpt; }
Cheers!
YigitJanuary 20, 2017 at 9:58 am #736310Thanks Yigit,
I had already managed to specify the number directly in the magazine.php in my child theme, as i had to modify that anyway. But the excerpt is not cutting off at the specified number of characters (75 in my case), but at the end of words, sometimes after 72, sometimes after 80, depending on the length of words…
I need it to cut directly at 75 (or a nother number i specify there).Cheers,
MaxJanuary 20, 2017 at 2:12 pm #736483Hi,
Please use the i posted earlier instead of editing the file directly.
Best regards,
YigitJanuary 23, 2017 at 9:12 am #737156Hi,
Ok i did.
Does not make any difference… Still cutting off after whole words!Regards,
MaxJanuary 23, 2017 at 2:52 pm #737268Hi,
Please post us your login credentials (in the “private data” field), so we can take a look at your backend.
Login credentials include:
- The URL to the login screen.
- A valid username (with full administration capabilities).
- As well as a password for that username.
- permission to deactivate plugins if necessary.
Best regards,
YigitJanuary 23, 2017 at 3:52 pm #737291Hi,
See private content!Thanks!
January 26, 2017 at 12:21 pm #738856Hi,
I am not sure if we are on the same page as it does seem to be working totally fine on my end. Please check out attached screenshots in private content field. I changed excerpt length from 75 to 70
Best regards,
YigitJanuary 26, 2017 at 12:24 pm #738859Hi,
I am sorry, but thats not a good example, because “Die” is a whole word. If you try to cut it off after 69 characters, what happens then?
Regards,
MaxJanuary 30, 2017 at 5:14 pm #740296Hi,
you can find it out by adjusting the code Yigit provided to you above. Adjust it until it fit to your needs.
Best regards,
AndyFebruary 1, 2017 at 10:17 am #741113Hi,
I think i still hanven’t made clear, what i am trying to do…
I want it to cut off after the EXACT Amount of characters specified even if that means in the middle of a word, but the provided code cuts at the end of the next word.
Example from the homepage:
Characters specified: 70
Keine monatlichen SAP-Meldungen sollen außer Acht gelassen werden. Die… (70)
Digitale Plattformen und ihre Geschäftsmodelle erobern Branche um Branche,… (74)
Bosch will eine der wichtigsten Einstiegshürden für kleinere Unternehmen…(72)
Viele KMU in Österreich haben Aufholbedarf bei Digitalisierung und Automatisierung…(82)See what i mean?
Cheers,
MaxFebruary 3, 2017 at 5:04 pm #742470Hi,
try this code inside of functions.php instead:
function get_excerpt(){ $excerpt = get_the_content(); $excerpt = preg_replace(" ([.*?])",'',$excerpt); $excerpt = strip_shortcodes($excerpt); $excerpt = strip_tags($excerpt); $excerpt = substr($excerpt, 0, 50); $excerpt = substr($excerpt, 0, strripos($excerpt, " ")); $excerpt = trim(preg_replace( '/s+/', ' ', $excerpt)); $excerpt = $excerpt.'... <a href="'.$permalink.'">more</a>'; return $excerpt; }
Best regards,
Andy -
AuthorPosts
- You must be logged in to reply to this topic.