• Resolved tproli

    (@tproli)


    Thanks for TablePress, I use it in many projects and it works perfectly.

    However, if there was a shortcode attribute to add “id” to the table, it would be great. For example, it could be an additional setting similar to “Extra CSS Classes”, for example “Element ID” or something.

    I often need to add jump links to tables, eg. example.com/#my-table, and currently I need to wrap the tablepress shortcode to achieve this.

    I know that TablePress automatically ads id to the table (id=”tablepress-14″) but that’s not so pretty-url friendly and there may be other elements above the table, eg. the table title and description (so the page would load at a position where these elements are cut).

    Thanks,
    tpr

    https://ww.wp.xz.cn/plugins/tablepress/

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 not really sure that offering this as a Shortcode parameter is a good idea or necessary. Due to the requirement that the ID has to be unique on the page, this can quickly lead to problems. Also, the ID is used by the JS features, so that have to be considered carefully.

    Instead, you could maybe use some custom code around the tablepress_html_id filter hook that is available in the controller-frontend.php file.
    However, as changing that HTML ID would not remedy the problem that you mention about the page loading at a position where the description or table name could be cut, a custom wrapper with your own HTML ID (which you could also add via a filter, like the tablepress_table_ouput filter hook) should be better here.

    Regards,
    Tobias

    Thread Starter tproli

    (@tproli)

    Hi,

    thanks for the tip, it sounds like an easy workaround, will try it.

    Btw, no troubles at all 🙂

    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 ‘Element id tag (shortcode)’ is closed to new replies.