Hi,
I use X with cornerstone.
I want to setup a pagetemplate which has an URL-parameter eg: “localhost/info/template/?id=1”
On this page I have an essential grid.
When id =1 I want to show essential grid “mygrid1”, when id = 2 I want to load grid “mygrid2”.
I tried to replace the shortcode with document.getElementById(“myGrid”).innerHTML= mynewGrid.
But at this point, the grid is already initialised and I am to late. Also replace shortcode in functions.php (child theme) is to late.
So I tried to set up in functions.php the following:
"function dbwcreateDynamicContent(string $content)
{
if (is_page(‘1209’)) {
// Do the processing etc…
//load the new shortcode from DB, based on the url-parameter
//then replace the dummy-shortcode with the real new shortcode using $content
//the dummy shortcode is "mydummy*
//the mynewgrid is the string for the new grid ‘[ess_grid alias=“berge”][/ess_grid]’
$newContent= str_replace(“mydummy”,$mynewgrid,$content);
$content = $newContent;
return $content;
}
"
I added this function :
“add_filter(‘the_content’, ‘dbwcreateDynamicContent’);”
Do I have a chance to dynamically replace the shortcode?
Martin