• Resolved AlluringBeauty

    (@alluringbeauty)


    I am trying to update the shortcode for tablepress to nest similarly to the code displayed here. I have a query string that will be equal to the id of the table that will need to display and have registered a shortcode to work with this. ex. [urlparam param=”forms1″ /]. I want to input the shortcode inside of the tablepress shortcode and do_shortcode() so it will display the correct table.

    [table id=[urlparam param=”forms1″ /]) /]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Tobias B?thge

    (@tobiasbg)

    Hi,

    thanks for your question, and sorry for the trouble.

    I’m afraid that this will not work like that. WordPress does not support nested Shortcodes inside other Shortcode attributes likes that, from what I know.
    Your best chance probably is to define a completely new Shortcode in PHP code, like

    add_shortcode( 'table-from-url-param', 'alluringbeauty_handle_table_from_url_param_shortcode' );
    function alluringbeauty_handle_table_from_url_param_shortcode( $attributes, $content ) {
    	if ( isset( $_GET['forms1'] ) ) {
    		$id = $_GET['forms1'];
    		$attributes['id'] = preg_replace( '/[^a-zA-Z0-9_-]/', '', $id );
    		return tablepress_get_table( $attributes );
    	} else {
    		return 'No table ID specified in the URL parameters.';
    	}
    }

    This would have to be added to your theme’s functions.php file or into a small custom plugin.

    Then, just use [table-from-url-param /] on the page to show the table with the ID that was passed in the forms1 URL parameter.

    Regards,
    Tobias

    Thread Starter AlluringBeauty

    (@alluringbeauty)

    Thank you! you saved me a ton of headache trying to figure this out.

    Plugin Author Tobias B?thge

    (@tobiasbg)

    Hi,

    no problem, you are very welcome! ?? Good to hear that this helped!

    Best wishes,
    Tobias

    P.S.: In case you haven’t, please rate TablePress here in the plugin directory. Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘how to dynamically display tables by nesting shortcodes’ is closed to new replies.