我嘗試在Wordpress中的引導模式窗口中打開帖子。目標是通過Ajax加載發佈的內容,因爲模式窗口放置在頁腳中。WordPress的:使用AJAX將帖子內容傳遞到div
這是我到現在爲止:
我的模板部分是在頁腳加載(modal.php)
<div class="modal fade" id="myModal-<?php the_ID(); ?>" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel"><?php the_title();?></h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<?php the_content();?>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
正如你所看到的,我會需要將一些內容從查詢傳遞到頁腳中的div。
我的鏈接,即打開模態窗口:
<a href="#" class="modal-link" data-toggle="modal" data-target="#myModal-<?php the_ID(); ?>" >View more</a>
那麼這將是解決這個最乾淨的方式是什麼?
感謝您的任何建議! 卡拉