Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Mikko Saari

    (@msaari)

    Add a filter on ‘pre_option_relevanssi_excerpt_length’ filter hook to modify the excerpt length on fly.

    add_filter('pre_option_relevanssi_excerpt_length', 'shorter_mobile_excerpt');
    function shorter_mobile_excerpt($length) {
        if (user is on mobile) $length = 100;
        return $length;
    }

    How to figure out when user is on mobile, I don’t know.

    Thread Starter briascoi

    (@briascoi)

    Sorry for my ignorance, I’ve never used a Filter in WP.

    Where do I put this? In functions.php?

    How do I call it?

    I already know how detect mobile, I’m using WP Detect Mobile plugin that extends WP with functions to detect mobile.

    Plugin Author Mikko Saari

    (@msaari)

    The code goes to functions.php (or anywhere else that gets executed), and the add_filter() function does the calling. All you need to do is to replace the “user is on mobile” with an actual mobile detection function.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Different quantity of words on Mobile and Desktop’ is closed to new replies.