內容簡介
這是為了深受歡迎的Advanced Custom Fields和TablePress插件所設計的擴展。這個插件本身是沒有任何功能的。
這個Advanced Custom Fields的附加功能建立了一個自定義字段類型,以選擇一個TablePress表格,提供一個下拉菜單,讓你從可用表格列表中選擇。該字段可以返回所選表格的表格ID或表格的完整HTML。
此插件需要:
Advanced Custom Fields版本4+或5+
TablePress版本1.5+
只要確保不會混淆...除非在您的網站上啟用了ACF(或ACF Pro)和TablePress,否則此插件不起作用。
在GitHub上關注此插件
使用該字段
當返回表格ID時,以下任何代碼片段都將輸出您的表格(將“ your_field_here”換為ACF Field Group設置中定義的字段名稱)。
<?php
$tablepress_id = get_field( 'your_field_here' );
echo do_shortcode( '[table id="'.$tablepress_id.'"]' );
?>
或者,為了避免使用do_shortcode(),使用
<?php
$tablepress_id = get_field( 'your_field_here' );
$args = array(
'id' => $tablepress_id,
);
if ( function_exists( 'tablepress_print_table' ) ) {
tablepress_print_table( $args );
}
?>
要在網頁上簡單地顯示所選表格,請在您的字段設置中選擇HTML輸出選項,然後將以下代碼插入您的php代碼:
the_field( 'your_field_here' );
有關詳細說明,請參閱我們的文章 Setting up an ACF field for TablePress 。
外掛標籤
開發者團隊
原文外掛簡介
This is an extension for the popular Advanced Custom Fields plugin and TablePress plugin. By itself, this plugin does NOTHING.
This add-on for Advanced Custom Fields creates a custom field type to select a TablePress table, providing a dropdown menu that lets you select from a list of available tables. The field can return the table ID for the table selected, or the full HTML of the table.
This plugin requires:
Advanced Custom Fields version 4+ or 5+
TablePress version 1.5+
Just to be sure there’s no confusion… This plugin does nothing unless ACF (Or ACF Pro) and TablePress are both active on your site
Follow this plugin on GitHub
Using the Field
This field can return the table ID for the table selected, or the full HTML of the table (the same output as the rendered shortcode).
When returning the table ID, either of the following code snippets will output your table (replacing ‘your_table_here’ with the field name you defined in your ACF Field Group settings).
or, to avoid using do_shortcode(), use
$tablepress_id,
);
if ( function_exists( 'tablepress_print_table' ) ) {
tablepress_print_table( $args );
}
?>
To simply display the chosen table on your page, choose the HTML output option in your field settings, and insert into your php with
the_field( 'your_field_here' );
For a more detailed explanation, see our article, Setting up an ACF field for TablePress.
