Wordpress Elementor Widget Change Excerpt Source

14 Views Asked by At

I am building a WordPress page with Moniz theme which uses Elementor. I put the Service widget on the homepage but not sure if it's Elementor based or built with Elementor by theme owners. The items which are listed in the widget is under "Services" menu on the admin panel, which is just a custom post_type. I'd like to use "excerpt" feature but saw that it's not supported by default. Then, I've added the feature in functions.php file like this:

add_action('after_setup_theme', function () {
  add_post_type_support('service', 'excerpt');
});

The excerpt field has appeared in service create/edit pages. But on the home page, in the service widget, the excerpts are still generating from post content even though I've entered a text in service edit page. Then I've searched the files and found only "moniz_excerpt" method in "template-functions.php" file. I've updated the method like this;

if (!function_exists('moniz_excerpt')) :

    // Post's excerpt text
    function moniz_excerpt($get_limit_value, $echo = true)
    {
        $opt = $get_limit_value;
        $excerpt_limit = !empty($opt) ? $opt : 40;
        $excerpt = /* added start */ get_the_excerpt() ?? /* added end */ wp_trim_words(get_the_content(), $excerpt_limit, '');
        if ($echo == true) {
            echo esc_html($excerpt);
        } else {
            return esc_html($excerpt);
        }
    }

endif;

The method starts from 212nd row in "template-functions.php". I don't have any ideas, is there anyone who faced this issue?

0

There are 0 best solutions below