Hi, @pvanbavel. Have you tried it this way:
echo do_shortcode( '[Best_Wordpress_Gallery id="21" gal_title="Name of User"]' );
Thnx. I hadn’t tried this before but this code works fine
<?php echo do_shortcode( '[Best_Wordpress_Gallery id="21" gal_title="Name of User"]' ); ?>
BTW, the [insert_php] shortcode does not work.
I’ve now removed all code from the WordPress Page and put it into a template file. So executing PHP is no problem anymore.
However I still have a problem with my page and that is that the above solution is hardcoded.
The short-code string is correctly contained within {{Best_Wordpress_Gallery}}
If a put {{Best_Wordpress_Gallery}} into a variable and put that variable into the below statement, things don’t work anymore.
What am I doing wrong?
Following is the complete source:
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://www.w3schools.com/lib/w3.css">
<link rel="stylesheet" href="http://www.w3schools.com/lib/w3data.js">
<script src="http://www.w3schools.com/lib/w3data.js"></script>
<script>
var Artists = {"artiesten":[
{"Naam":"User-1","Discipline":"Schilderen", "Best_Wordpress_Gallery":"[Best_Wordpress_Gallery id=\"20\" gal_title=\"User-1\"]"},
{"Naam":"User-2","Discipline":"Schilderen", "Best_Wordpress_Gallery":"[Best_Wordpress_Gallery id=\"21\" gal_title=\"User-2\"]"},
{"Naam":"User-3","Discipline":"Schilderen", "Best_Wordpress_Gallery":"[Best_Wordpress_Gallery id=\"21\" gal_title=\"User-3\"]"},
{"Naam":"User-4","Discipline":"Schilderen", "Best_Wordpress_Gallery":"[Best_Wordpress_Gallery id=\"21\" gal_title=\"User-4\"]"}
]};
</script>
</head>
<body>
<section id="index" class="w3-container w3-section w3-padding-small">
<nav class="w3-top w3-sidenav w3-sand w3-animate-left w3-margin-top" style="display:none">
<a href="javascript:void(0)" onclick="w3_close()" class="w3-closenav w3-large w3-pale-yellow w3-center">Close ×</a>
<ul id="id03" class="w3-container w3-ul" onmouseleave="w3_close()">
<li class="w3-border-0" w3-repeat="artiesten" ><a onmouseclick="w3_close()" href="#{{Naam}}" >{{Naam}}: {{Discipline}}</a></li>
</ul>
</nav>
<div id="rest" class="w3-container w3-rest"> </div>
</section>
<section id="Per Kunstenaar" class="w3-container ">
<ul id="id04" class="w3-container w3-ul">
<li class="w3-border-0" w3-repeat="artiesten" >
<div class="w3-container w3-center ">
<h3 class="w3-container w3-margin-top">{{Naam}}</h3>
{{Best_Wordpress_Gallery}}
<?php
echo do_shortcode( '[Best_Wordpress_Gallery id="21" gal_title="User-2"]' );
?>
</div>
<div class="w3-container w3-center w3-margin-top">
<span class="w3-opennav w3-large w3-border " onclick="w3_open()">☰ Namenlijst </span>
<!-- "☰" : Unicode code for menu hamburger -->
</div>
</li>
</ul>
</div>
</section>
<script type="text/javascript" charset="utf-8" async defer>
w3DisplayData("id03", Artists);
</script>
<script type="text/javascript" charset="utf-8" async defer>
w3DisplayData("id04", Artists);
</script>
<script type="text/javascript" charset="utf-8" async defer>
function w3_open() {
document.getElementsByClassName("w3-sidenav")[0].style.width = "20%";
document.getElementsByClassName("w3-sidenav")[0].style.display = "block";
}
</script>
<script type="text/javascript" charset="utf-8" async defer>
function w3_close() {
document.getElementsByClassName("w3-sidenav")[0].style.display = "none";
}
</script>
</body>
The result should be a separate section per artist, consisting of his/her name, a small photo gallery and a “Namenlijst” (=’NameList’) button
Much appreciated if you could help me out.