在文章裡面新增幻燈片的方法有很多,但網路上好像比較少再講直接加在首頁裡面的
安裝這個外掛
Content Slide Plugin
然後把下面那兩段程式碼加進去,依照你的需求而定
Add PHP code
To display WordPress content slide on your website you have to add following lines of code inside your themes .php files.
|
1
|
<?php if(function_exists('wp_content_slider')) { wp_content_slider(); } ?> |
Example if you want to display this slider in your header then you have to edit the header.php file. Just open header.php from your current theme in any editor and add
|
1
|
<?php if(function_exists('wp_content_slider')) { wp_content_slider(); } ?> |
lines at the location where you want to display the slider.
Slider Only On Home Page
In some cases you just want to display slider only on the home page in this case you have selected a page as home page from the settings->reading section.
And if your home page is using default page template then you have to add following lines of code in your page.php at the location where you want to display the slider.
|
1
|
<?php if(is_front_page()) { if(function_exists('wp_content_slider')) { wp_content_slider(); } } ?> |
Using above code the slider will be displayed only on home page.
Slider on a Specific page
If you want to display slider on a specific page say ‘about’ then you have to use wordpress conditional tags
|
1
|
<?php if(is_page('about')) { if(function_exists('wp_content_slider')) { wp_content_slider(); } } ?> |
參考網址:http://www.snilesh.com/resources/wordpress/wordpress-plugins/wordpress-content-slide-plugin/
