內容簡介
此外掛可從自訂文章中創建基本手風琴。
與WPML完全相容,只需翻譯您的文章並使用下面說明的短代碼。
此外掛目前不支援Woocommerce。
使用說明
要使用此外掛,您需要註冊自訂文章。
您可以查看文章類型以了解如何進行設置。
以下是WP Codex的示例 - 如需測試,將下面的代碼複製貼上到佈景功能文件。
add_action( 'init', 'create_post_type' );
function create_post_type() {
register_post_type( 'Accordion',
array(
'labels' => array(
'name' => __( '手風琴' ),
'singular_name' => __( '手風琴' )
),
'public' => true,
'has_archive' => true,
)
);
}
在您想要使用手風琴的頁面或文章中添加短代碼
如果您使用以上代碼創建自訂文章類型,則可以使用以下短代碼:
[gw_accordion post_type="Accordion"]
也可以添加CSS類別
[gw_accordion post_type="Accordion" class="my_css_class"]
您還可以將代碼添加到主題中
<?php echo do_shortcode('[gw_accordion post_type="Accordion"');?>
或者帶有CSS類別
<?php echo do_shortcode('[gw_accordion post_type="Accordion" class="my_css_class"]');?>
您還可以設置排序,默認按ID升序排列
[gw_accordion post_type=”Accordion” class=”my_css_class” order_by=”title” order=”asc”]
演示
查看演示
已知問題
如果您的主題使用類似於此的平滑滾動腳本
jQuery(function() {
jQuery('a[href*="#"]:not([href="#"]').click(function() {
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
var target = jQuery(this.hash);
target = target.length ? target : jQuery('[name=' + this.hash.slice(1) +']');
if (target.length) {
jQuery('html,body').animate({
scrollTop: target.offset().top
}, 2000);
return false;
}
}
});
});
您可能需要更改此行
jQuery('a[href*="#"]:not([href="#"]')
讓它看起來像這樣
jQuery('a[href*="#"]:not([href="#"], a:not([data-toggle])')
避免衝突。
外掛標籤
開發者團隊
原文外掛簡介
This plugin creates a basic accordion from custom posts.
Fully compatible with WPML, just translate your posts and use shortcodes as explained below.
The plugin currently does not support Woocommerce.
How to use
To use this plugin you need custom post registered.
You may check Post Types to see how to do it.
Example from WP Codex – for testing, copy and paste code below to theme functions.php
add_action( 'init', 'create_post_type' );
function create_post_type() {
register_post_type( 'Accordion',
array(
'labels' => array(
'name' => __( 'Accordions' ),
'singular_name' => __( 'Accordion' )
),
'public' => true,
'has_archive' => true,
)
);
}
Add shortcode to page or post where you want to use accordion
If you used code above to create custom posts type you would use following shortcode:
[gw_accordion post_type="Accordion"]
Optionally, you may add CSS class
[gw_accordion post_type="Accordion" class="my_css_class"]
You can also add code to your theme
or with the CSS class
You also may set ordering, default is by ID and Ascending (ASC)
[gw_accordion post_type=”Accordion” class=”my_css_class” order_by=”title” order=”asc”]
Demo
Check Demo
Known Issues
If your theme uses smooth scroll script like this one
jQuery(function() {
jQuery('a[href*="#"]:not([href="#"]').click(function() {
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
var target = jQuery(this.hash);
target = target.length ? target : jQuery('[name=' + this.hash.slice(1) +']');
if (target.length) {
jQuery('html,body').animate({
scrollTop: target.offset().top
}, 2000);
return false;
}
}
});
});
You may need to change this line
jQuery('a[href*="#"]:not([href="#"]')
To look like this
jQuery('a[href*="#"]:not([href="#"], a:not([data-toggle])')
to avoid conflict
