Hi all!
To get infinite scrolling on some projects of mine I often use Ajax Load More via load_template().
It worked like a charm in Sage 8, but now I’m wondering what’s the correct way to get third-party plugins to source partials and views.
On the same topic, before Blade I wrote a catch-all shortcode which allowed me to insert arbitrary pieces of code directly from the WP editor:
/**
* Shortcode to get arbitary widgets with content
*/
add_shortcode('widgetc', function ($atts, $content) {
extract($atts);
ob_start();
include(locate_template('views/partials/widget-' . $tpl . '.php'));
return ob_get_clean();
});
Clearly this does not work anymore with Blade templates, so what’s the correct way to achieve a similar result?
Thank you, the same code works wonderfully as an ALM template.
I still have an issue because within Sage ALM fails to include its JS:
The alm_render_shortcode function is being called before the wp_enqueue_scripts, so the wp_enqueue_script('ajax-load-more') comes before registering the script itself.
If I manually add if (is_home() || is_category()) { // Enqueue core Ajax Load More JS wp_enqueue_script('ajax-load-more'); wp_enqueue_script('ajax-load-more-seo'); }
in my own enqueue function, ALM works again.
Any hint?
Did you ever find a solution for this? Experiencing the same issue currently. I figured out to enqueue the script manually, which is now loading the JavaScript I need. However, despite an Ajax request being fired off now, the response is never appended to the page.