Multiple bpopup with shortcode content

I’m trying to use bpopup plugin for a several different contents and this code works fine

(function ($) {
        $(function() {
            $('#parent').on('click', 'a.button', function (e) {
    e.stopPropagation();
    e.preventDefault();
    var popup = $(this).attr('href');
    $('#'+popup).bPopup();
});
        });
    })(jQuery);
.element_to_pop_up { 
    background-color:#fff;
    border-radius:0px;
    border:0px;
    color:#000;
    display:none; 
    padding:20px;
    min-width:400px;
    min-height: 180px;
}
.b-close{
    cursor:pointer;
    position:absolute;
    right:10px;
    top:5px;
}
<div id="parent">               
<a href="popup_1" class="button">click me</a><div id="popup_1" class="element_to_pop_up">content<a class="b-close">X</a></div>                                                
<a href="popup_2" class="button">click me 2</a><div id="popup_2" class="element_to_pop_up">content 2<a class="b-close">X</a></div>
<a href="popup_3" class="button">click me 3</a><div id="popup_3" class="element_to_pop_up">content 3<a class="b-close">X</a></div>
</div>  

But if i try to replace the text content by php shortcode, works just the first popup and the others are directed to a wrong location by “a href”. I have a php array database of employee and i need to each of them display in another popup by shortcode.

<div id="parent">               
    <a href="popup_1" class="button">click me</a><div id="popup_1" class="element_to_pop_up">
  <?php echo do_shortcode('[name="1"]'); ?><a class="b-close">X</a></div>                                                
    <a href="popup_2" class="button">click me 2</a><div id="popup_2" class="element_to_pop_up">
  <?php echo do_shortcode('[name="2"]'); ?><a class="b-close">X</a></div>
    <a href="popup_3" class="button">click me 3</a><div id="popup_3" class="element_to_pop_up">
  <?php echo do_shortcode('[name="3"]'); ?><a class="b-close">X</a></div>
    </div>

I guess that php does something wrong with #parent, but i really don’t know what and why.. I’m not a coding master

Any ideas? Please…


Source: shortcode

Leave a Reply