導航:首頁 > 編程語言 > phpjquery瀑布流代碼

phpjquery瀑布流代碼

發布時間:2024-11-28 05:59:28

⑴ 如何在wordpress網站添加瀑布流單頁模板

<?php
/*
TEMPLATENAME:瀑布流測試
*/
//基於Wordpress自帶的2014主題
//貢獻者:Suifengtecsuoling.net
if(!function_exists('coolwp_scripts_masonry')):
if(!is_admin()):
functioncoolwp_scripts_masonry(){
//.
wp_deregister_script('jquery-masonry');
//請自行下載
wp_enqueue_script('jquery-10.1.js',get_template_directory_uri().'/test/jquery.js',array('imagesLoaded'),null,true);
//請自行下載
wp_enqueue_script('imagesLoaded',get_template_directory_uri().'/test/imagesloaded.pkgd.min.js',false,null,true);
//請自行下載
wp_enqueue_script('jquery-masonry',get_template_directory_uri().'/test/masonry.pkgd.min.js',array('imagesLoaded'),null,true);
//後面我貼出來
wp_enqueue_script('custom.js',get_template_directory_uri().'/test/custom.js',array('imagesLoaded'),null,true);
}

//wp_enquqe_style('masonry',get_template_directory_uri().'/test/');

add_action('wp_enqueue_scripts','coolwp_scripts_masonry');
endif;//!is_admin()
endif;//!coolwp_scripts_masonryexists?
get_header();?>

<divid="main-content"class="main-content">

<?php
if(is_front_page()&&twentyfourteen_has_featured_posts()){
//.
get_template_part('featured-content');
}
?>
<divid="primary"class="content-area">
<divid="content"class="site-content"role="main">

<?php
$args=array('post_type'=>'post');
$myloop=newWP_Query($args);
//StarttheLoop.
while($myloop->have_posts()):$myloop->the_post();

//Includethepagecontenttemplate.
?>

<divclass="item">
<?php
if(has_post_thumbnail()):?>
<divclass="masonry-thumbnail">
<ahref="<?phpthe_permalink()?>"title="<?phpthe_title();?>">
<?phpthe_post_thumbnail('thumbnail');?></a>
</div><!--.masonry-thumbnail-->
<?phpendif;?>
<divclass="masonry-details">
<h5><ahref="<?phpthe_permalink('')?>"title="<?phpthe_title();?>"><spanclass="masonry-post-title"><?phpthe_title();?></span></a></h5>
<!--<divclass="masonry-post-excerpt">
<?phpthe_excerpt();?>
</div>--><!--.masonry-post-excerpt-->
</div><!--/.masonry-entry-details-->
</div><!--/.item-->
<?phpendwhile;?>
</div><!--#content-->
</div><!--#primary-->
<?php//get_sidebar('content');?>
</div><!--#main-content-->

<?php
get_sidebar();
get_footer();


custom.js代碼

varcontainer=document.querySelector('#content');
varmsnry=newMasonry(container,{
columnWidth:200,
itemSelector:'.item'
});

/*alert('aaaaa');*/


將你下載到的三個js文件和上面的custom.js放在你的WP的2014主題目錄下的test文件夾(自己建),然後將上面的PHP代碼復制到一個英文開頭的PHP文件里,把這個PHP文件放在WP的2014主題目錄下,

啟用這個主題,發布頁面,選用「瀑布流測試」頁面模板,如果你的測試WP中有文章,並且文章有縮略圖,就會是這個樣子:


只需要你改下查詢語句和css,就可以套用到別的主題了。

閱讀全文

與phpjquery瀑布流代碼相關的資料

熱點內容
java爬蟲解析html 瀏覽:861
約瑟夫集合java 瀏覽:275
我的ie8網站顯示不居中 瀏覽:423
win10圖片原地址在哪顯示 瀏覽:201
怎麼樣把app添加到小組件 瀏覽:148
省內順豐郵文件多少錢 瀏覽:715
絕密級文件應保留多少年 瀏覽:701
發文件給同事怎麼說 瀏覽:468
蘋果80歲用什麼app 瀏覽:28
順豐寄快遞文件多少錢 瀏覽:164
消費邦app是怎麼反現的 瀏覽:112
java調用介面方法 瀏覽:742
微信一種以上綁定關系 瀏覽:183
word圖片編輯大小邊框 瀏覽:468
威迅java培訓 瀏覽:389
linux禪道無法訪問 瀏覽:819
怎麼爬取歷史疫情數據 瀏覽:596
linuxjira6破解 瀏覽:694
哪個網站可以看所有檢察雜志 瀏覽:144
java高並發資料庫請求怎麼辦 瀏覽:551

友情鏈接