Home / Widgets / Tablepress_get_cell
Duplicate Snippet

Embed Snippet on Your Site

Tablepress_get_cell

Code Preview
php
<?php
function tablepress_cell_to_url_shortcode( $atts ) {
    $atts = shortcode_atts( array(
        'table_id' => '',
        'row'      => 1,
        'col'      => 1,
        'page'     => '', // Zielseite
        'param'    => 'wert', // Parametername
    ), $atts, 'tablepress_link' );
    $table_data = tablepress_get_table( $atts['table_id'], true );
    if ( empty( $table_data ) ) {
        return 'Tabelle nicht gefunden.';
    }
    $cell_content = $table_data[ $atts['row'] - 1 ][ $atts['col'] - 1 ] ?? '';
    if ( empty( $cell_content ) ) {
        return 'Zelle leer.';
    }
    $url = add_query_arg( $atts['param'], urlencode( $cell_content ), home_url( $atts['page'] ) );
    return '<a href="' . esc_url( $url ) . '">Zur neuen Seite</a>';
}
add_shortcode( 'tablepress_link', 'tablepress_cell_to_url_shortcode' );

Comments

Add a Comment