• Resolved vision64

    (@vision64)


    Hi

    I noticed that once I activate the plugin “tablepress” no acf-tables are rendered.

    Message in my browser: [table “” not found /]

    If i disable tablespress it works again.

    Is there a way to have your plugin work in together with tablepress?

    Thanks
    Uwe

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author Johann Heyne

    (@jonua)

    Hi,

    “Tablepress” uses the shortcode [table] which you may also defined to output the tablefield′s table. If so, all you have to do is renaming the shortcode for outputting the tablefield table like add_shortcode( 'tablefield', … );

    Cheers,
    Johann

    Thread Starter vision64

    (@vision64)

    hi

    you mean in the functions.php?

    can you send me an example code please?

    Thanks a lot
    Uwe

    Plugin Author Johann Heyne

    (@jonua)

    Well, the issue seems to be a name conflict of two shortcodes named “table”. Did you add a code like add_shortcode( 'table', … ); by yourself in the functions.php?

    Thread Starter vision64

    (@vision64)

    Hi

    I currently do use the following code in my functions.php (copied from a support ticket here and modified it to output also the table caption:

    
    function shortcode_acf_tablefield( $atts ) {
        $a = shortcode_atts( array(
            'field-name' => false,
            'post-id' => false,
        ), $atts );
    
        $table = get_field( $a['field-name'], $a['post-id'] );
    
        $return = '';
    
    		if ( ! empty( $table['caption'] ) ) {
    			$return .= '<div class="table-title">' . $table['caption'] . '</div>';
    		}
    			
    			
        if ( $table ) {
    
            $return .= '<table class="product-tables">';
    
                if ( $table['header'] ) {
    
                    $return .= '<thead>';
    
                        $return .= '<tr>';
    
                            foreach ( $table['header'] as $th ) {
    
                                $return .= '<th>';
                                    $return .= $th['c'];
                                $return .= '</th>';
                            }
    
                        $return .= '</tr>';
    
                    $return .= '</thead>';
                }
    
                $return .= '<tbody>';
    
                    foreach ( $table['body'] as $tr ) {
    
                        $return .= '<tr>';
    
                            foreach ( $tr as $td ) {
    
                                $return .= '<td>';
                                    $return .= $td['c'];
                                $return .= '</td>';
                            }
    
                        $return .= '</tr>';
                    }
    
                $return .= '</tbody>';
    
            $return .= '</table>';
        }
    
        return $return;
    }
    
    add_shortcode( 'table', 'shortcode_acf_tablefield' );

    The shortcode I am using to render the table is: [table field-name=”my-tablename”]

    Thanks very much for you help in advance

    Uwe

    Thread Starter vision64

    (@vision64)

    I tried to replace all $table with $tabletest but that doesnt seem to work either.

    WP display now the shortcode instead of [table “” not found /]

    Hope you can help me ??

    Uwe

    Plugin Author Johann Heyne

    (@jonua)

    Hi,

    you must change add_shortcode( 'table', 'shortcode_acf_tablefield' ); into add_shortcode( 'tablefield', 'shortcode_acf_tablefield' ); and then using [tablefield field-name="my-tablename"] to output a tablefields table.

    Cheers,
    Johann

    • This reply was modified 4 years, 11 months ago by Johann Heyne.
    • This reply was modified 4 years, 11 months ago by Johann Heyne.
    • This reply was modified 4 years, 11 months ago by Johann Heyne.
    Thread Starter vision64

    (@vision64)

    Hi Johann

    awesome – works like charm.

    Thanks very much for the fast and good help

    Uwe

    Hi,

    good to hear that you guys found the solution already! ??

    Best wishes,
    Tobias

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Using “Tablepress” causes issues’ is closed to new replies.