Skip to main content
The cart is empty

Grid item with dynamic content

Since Yootheme Builder 3.0.23 and Falang for Yootheme lite 1.5 this change are no more necessary. A filter was added in Yootheme Builder to solve this problem.

Grid item with dynamic content that display content or teaser need a fix (tested with version 2.7.25 of Yootheme Pro for WordPress)

2 methods must be modified in the File wp-content/themes/yootheme/vendor/yootheme/builder-wordpress-source/src/Type/PostType.php

1) Content version 2.7.14 (yootheme)

The orgiinal source code with content 2 parameters

    public static function content($post, $args)
    {
        global $page, $numpages, $multipage;

        $args += ['show_intro_text' => true];

        // Hint: this returns different results depending on the current view (archive vs. single page)
        $content = get_the_content('', !$args['show_intro_text'], $post);
        $content = str_replace("<span id=\"more-{$post->ID}\"></span>", '', $content);

        if ($multipage && Helper::isPageSource($post)) {
            $title = sprintf(__('Page %s of %s', 'yootheme'), $page, $numpages);
            $content =
                '<p class="uk-text-meta tm-page-break' .
                ($page == '1' ? ' tm-page-break-first-page' : '') .
                "\">{$title}</p>{$content}" .
                link_pages();
        }

        if (!has_blocks($content) && !app(Config::class)('~theme.disable_wpautop')) {
            // trim leading whitespace, because ` </div>` results in `</p></div>
            $content = wpautop(preg_replace('/^\s+<\//m', '</', $content));
        }

        return $content;
    }

The modified source code

    public static function content($post, $args)
    {
        global $page, $numpages, $multipage;

        $args += ['show_intro_text' => true];

        // Hint: this returns different results depending on the current view (archive vs. single page)
        //sbou
        $post_id = $post->ID;
        global $post;
        $post = get_post($post_id);
        setup_postdata( $post );
        $content = get_the_content('', !$args['show_intro_text'], $post);
        $content = apply_filters('the_content',$content);
        wp_reset_postdata();
        $content = str_replace("<span id=\"more-{$post->ID}\"></span>", '', $content);

        if ($multipage && Helper::isPageSource($post)) {
            $title = sprintf(__('Page %s of %s', 'yootheme'), $page, $numpages);
            $content =
                '<p class="uk-text-meta tm-page-break' .
                ($page == '1' ? ' tm-page-break-first-page' : '') .
                "\">{$title}</p>{$content}" .
                link_pages();
        }

        if (!has_blocks($content) && !app(Config::class)('~theme.disable_wpautop')) {
            // trim leading whitespace, because ` </div>` results in `</p></div>
            $content = wpautop(preg_replace('/^\s+<\//m', '</', $content));
        }

        return $content;
    }

2) Content version 2.7.25 (yootheme)

the signature of the content method has changed

with content method with 3 parameters the orignial method is 

    public static function content($post, $args, $context)
    {
        global $page, $numpages, $multipage;

        $args += ['show_intro_text' => true];

        // Hint: this returns different results depending on the current view (archive vs. single page)
        $content = get_the_content('', !$args['show_intro_text'], $post);
        $content = str_replace("<span id=\"more-{$post->ID}\"></span>", '', $content);

        if ($multipage && !empty($context['isPageSource'])) {
            $title = sprintf(__('Page %s of %s', 'yootheme'), $page, $numpages);
            $content = '<p class="uk-text-meta tm-page-break' . ($page == '1' ? ' tm-page-break-first-page' : '') . "\">{$title}</p>{$content}" . link_pages();
        }

        if (!has_blocks($content) && !app(Config::class)('~theme.disable_wpautop')) {
            $content = wpautop($content);
        }

        return $content;
    }

the modified method is 

    public static function content($post, $args, $context)
    {
        global $page, $numpages, $multipage;

        $args += ['show_intro_text' => true];

        // Hint: this returns different results depending on the current view (archive vs. single page)
        //sbou
        $post_id = $post->ID;
        global $post;
        $post = get_post($post_id);
        setup_postdata( $post );
        $content = get_the_content('', !$args['show_intro_text'], $post);
        $content = apply_filters('the_content',$content);
        wp_reset_postdata();
        //end sbou
        $content = str_replace("<span id=\"more-{$post->ID}\"></span>", '', $content);

        if ($multipage && !empty($context['isPageSource'])) {
            $title = sprintf(__('Page %s of %s', 'yootheme'), $page, $numpages);
            $content = '<p class="uk-text-meta tm-page-break' . ($page == '1' ? ' tm-page-break-first-page' : '') . "\">{$title}</p>{$content}" . link_pages();
        }

        if (!has_blocks($content) && !app(Config::class)('~theme.disable_wpautop')) {
            $content = wpautop($content);
        }

        return $content;
    }

3 ) Teaser

Original method

    public static function teaser($post, $args)
    {
        $args += ['show_excerpt' => true];

        if ($args['show_excerpt'] && has_excerpt($post)) {
            return get_the_excerpt($post);
        }

        $extended = get_extended($post->post_content);
        $teaser = $extended['main'];

        // Having multiple `<!-- wp:more -->` blocks confuses the parse_blocks function
        if (has_blocks($teaser)) {
            $teaser = do_blocks($teaser);
        }

        return $teaser;
    }

Modified method

    public static function teaser($post, $args)
    {
        $args += ['show_excerpt' => true];

        if ($args['show_excerpt'] && has_excerpt($post)) {
            return get_the_excerpt($post);
        }
        //sbou
        $post_id = $post->ID;
        global $post;
        $post = get_post($post_id);
        setup_postdata( $post );
        $extended = get_extended(apply_filters('the_content',$post->post_content));
        wp_reset_postdata();
        //$extended = get_extended($post->post_content);
        //fin sbou
        $teaser = $extended['main'];

        // Having multiple `<!-- wp:more -->` blocks confuses the parse_blocks function
        if (has_blocks($teaser)) {
            $teaser = do_blocks($teaser);
        }

        return $teaser;
    }