導航:首頁 > 編程語言 > 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瀑布流代碼相關的資料

熱點內容
maya粒子表達式教程 瀏覽:84
抖音小視頻如何掛app 瀏覽:283
cad怎麼設置替補文件 瀏覽:790
win10啟動文件是空的 瀏覽:397
jk網站有哪些 瀏覽:134
學編程和3d哪個更好 瀏覽:932
win10移動硬碟文件無法打開 瀏覽:385
文件名是亂碼還刪不掉 瀏覽:643
蘋果鍵盤怎麼打開任務管理器 瀏覽:437
手機桌面文件名字大全 瀏覽:334
tplink默認無線密碼是多少 瀏覽:33
ipaddgm文件 瀏覽:99
lua語言編程用哪個平台 瀏覽:272
政采雲如何導出pdf投標文件 瀏覽:529
php獲取postjson數據 瀏覽:551
javatimetask 瀏覽:16
編程的話要什麼證件 瀏覽:94
錢脈通微信多開 瀏覽:878
中學生學編程哪個培訓機構好 瀏覽:852
榮耀路由TV設置文件共享錯誤 瀏覽:525

友情鏈接