我想在索引中顯示我的參考作品。我限制的話。我的目標是:想要了解關於帖子的詳細信息的用戶,將點擊帖子縮略圖,其餘內容將會彈出。如何在Wordpress中製作彈出式博客內容
我用w3css模式來製作它。我的javascript代碼是:
// Get the modal
var modal = document.getElementById('myModal');
// Get the button that opens the modal
var btn = document.getElementById("myBtn");
// Get the <span> element that closes the modal
var span = document.getElementsByClassName("close")[0];
// When the user clicks on the button, open the modal
btn.onclick = function() {
modal.style.display = "block";
}
// When the user clicks on <span> (x), close the modal
span.onclick = function() {
modal.style.display = "none";
}
// When the user clicks anywhere outside of the modal, close it
window.onclick = function(event) {
if (event.target == modal) {
modal.style.display = "none";
}
}
但只有第一篇文章似乎是這樣的。其他人沒有反應。
謝謝。
I want to make all thumbnails like that
我做了一些修改有關。我用的fancybox 2和更改代碼才能使用此
<a href="#inline1" rel="gallery" class="fancybox"><?php the_post_thumbnail('thumbnail', array('class' => 'aligncenter')); ?></a>
<div id="inline1" style="width:400px;display: none;">
<?php the_post_thumbnail('thumbnail', array('class' => 'aligncenter')); ?><?php the_content(); ?>
</div>
現在所有的縮略圖用的fancybox但此時其他縮略圖內容是相同的先上後打開。
您將需要複製該代碼,並創建一個模態元素在HTML中的每張圖片。這聽起來不對,我會研究一個模式插件或其他東西。 – yuriy636
我對此做了一些修改。現在所有的縮略圖都用fancybox打開,但這次其他縮略圖的內容與第一篇文章相同。你能找到其他的嗎? @ yuriy636 – Katzenliebe
可能的重複[爲什麼fancybox內容是相同的WordPress的?](http://stackoverflow.com/questions/38871689/why-fancybox-contents-are-the-same-in-wordpress) –