dudaster / ele-custom-skin

Create a skin for Elementor Pro Post and Post Archive widgets using Elementor templates
GNU General Public License v3.0
59 stars 10 forks source link

Dynamic Everywhere examples #284

Open hiviz opened 4 years ago

hiviz commented 4 years ago

https://dudaster.com/dynamic-everywhere/ shows one example of implementing Dynamic Everywhere feature.

Can you please provide more examples so I can study and emulate this feature for my own use case?

Additionally, the example provided is specific to Eletheme - i.e. the hook "ecs_vars" does not exist for any other theme. What hook should I be looking for when using any other theme?

dudaster commented 4 years ago

So you want to use this feature outside the loop templates?

hiviz commented 4 years ago

Both inside and outside loop templates

dudaster commented 4 years ago

For inside it is pretty simple: use {{name_of_custom_field}} and it will be replaced with the value. Currently it is not working with links... elementor eliminates the curly brackets from links now it seems.

Outside you need to make a content filter that you need to add it in functions.php that looks like this:

add_filter( 'the_content', 'filter_the_content_in_the_main_loop', 1 );

function filter_the_content_in_the_main_loop( $content ) {

    // Check if we're inside the main loop in a single Post.
    if ( is_singular() && in_the_loop() && is_main_query() ) {
        return ecs_parse_content($content);
    }

    return $content;
}
hiviz commented 4 years ago

Is the content filter added in functions.php essentially "manually" doing what the ACF plugin (https://www.advancedcustomfields.com) plugin does?

dudaster commented 4 years ago

Actually is not limited only to ACF. Any meta key will work.

hiviz commented 4 years ago

I see - and after you create your custom meta, you can dynamically call it into the loop template via the curly braces syntax?

dudaster commented 4 years ago

Pretty much

hiviz commented 4 years ago

Understood. Thanks very much!