WordPress.org

Forums

TablePress
[resolved] Single Cell Content Shortcode in Text Widget (4 posts)

  1. rdellconsulting
    Member
    Posted 1 year ago #

    Having just discovered this extension to your wonderful plugin (I just donated!), the simple shortcode:
    [table-cell id=1 cell=A1 /]
    works on a Page, but doesn't work in the WP Text Widget in a sidebar.

    What did I miss?

  2. TobiasBg
    Member
    Plugin Author

    Posted 1 year ago #

    Hi,

    thanks for your post (and for the donation!), and sorry for the trouble.

    That's correct, as WordPress does not run Shortcodes in text widgets in general. TablePress works around this for the [table] Shortcode, and it's easy to do the same for the Extension. Just add this to the end of the Extension's .php file:

    if ( ! is_admin() ) {
    	add_filter( 'widget_text', 'table_single_cell_widget_text_filter' );
    }
    function table_single_cell_widget_text_filter( $content ) {
    	global $shortcode_tags;
    	$orig_shortcode_tags = $shortcode_tags;
    	$shortcode_tags = array();
    	add_shortcode( 'table-cell', 'tablepress_table_cell_shortcode' );
    	$content = do_shortcode( $content );
    	$shortcode_tags = $orig_shortcode_tags;
    	return $content;
    }

    Regards,
    Tobias

  3. rdellconsulting
    Member
    Posted 1 year ago #

    Perfect thanks.

    I provide support for the Customizr theme where I promote child themes. Just looked it up to see if there is a child plugin concept and there doesn't seem to be.

    So I need to add this code if you ever update the plugin, or how would you recommend I do that (other than manually)?

  4. TobiasBg
    Member
    Plugin Author

    Posted 1 year ago #

    Hi,

    yes, you would have to readd the code, but as those Extensions don't get auto-updated (they are not in the WordPress Plugin Repository), the update process is manual anyway.

    Regards,
    Tobias

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • TablePress
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic