Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #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,
    Max

    #736048

    Hi 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!
    Yigit

    #736310

    Thanks 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,
    Max

    #736483

    Hi,

    Please use the i posted earlier instead of editing the file directly.

    Best regards,
    Yigit

    #737156

    Hi,

    Ok i did.
    Does not make any difference… Still cutting off after whole words!

    Regards,
    Max

    #737268

    Hi,

    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,
    Yigit

    #737291

    Hi,
    See private content!

    Thanks!

    #738856

    Hi,

    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,
    Yigit

    #738859

    Hi,
    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,
    Max

    #740296

    Hi,

    you can find it out by adjusting the code Yigit provided to you above. Adjust it until it fit to your needs.

    Best regards,
    Andy

    #741113

    Hi,

    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,
    Max

    #742470

    Hi,

    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

Viewing 12 posts - 1 through 12 (of 12 total)
  • You must be logged in to reply to this topic.