Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author MikeShaw217

    (@mikeshaw217)

    Hi there,

    First of all, sorry it’s taken so long to reply to you! For some reason, I don’t get notified of new support threads of my plugin!

    twigpress_get_the_content() is used to return the content of a post with proper formatting.

    When you call the_content() in a normal template, it goes through a stage of formatting (it isn’t stored in the database as you see it on the front-end).

    However, the function get_the_content() (which returns rather than echoes) it is returned without the formatting done.

    Essentially, twigpress_get_the_content() takes care of formatting the content before returning it to you

    I hope this makes sense! If not, let me know and I’ll try and explain it better ??

    I’ll also work on some code examples, to show how to pass data into Twig templates ??

    Mike

    Thread Starter gaintsev

    (@gaintsev)

    Hi Mike!

    Thanks for you answer! I had the time to understand how it works. =)
    Now I want to use the ‘twigpress’ on the new site and I have a new question. How can I apply filter ‘twigpress_twig_global_functions’? Now I add new functions directly into the plugin code. And I understand that this is wrong, but I do not understand how to use ‘twigpress_twig_global_functions’ to add new features.

    Hope to help. Thanks. ??

    Plugin Author MikeShaw217

    (@mikeshaw217)

    Hey,

    No problem! You can use the filter in your functions.php file like any other. It takes, as a parameter, an array of function names already registered which you can alter and then return

    function add_functions_to_twig_environment($functions)
    {
        return array_merge($functions, array(
            'function_one_name',
            'function_two_name'
        ));
    }
    
    add_filter('twigpress_twig_global_functions', 'add_functions_to_twig_environment', 10, 1);

    The array is simply an array of function names, which will be made available in your templates

    Hope this helps!

    Mike

    Thread Starter gaintsev

    (@gaintsev)

    This work perfect! Many thanks Mike! )

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Function the_content() and loop in Twig templates’ is closed to new replies.