Support » Plugin: TablePress » Changing h2 tags

  • Resolved msilvertant

    (@msilvertant)


    Hello, your plugin is fantastic, but a problem just came up. I noticed that your tables automatically get h2 tags when including the title. But I’m using this Table of Contents plugin that creates an index out of all h2 tags in a post automatically, meaning that tables are basically counted as chapters now on my blog posts.

    For this reason, I really need to change the h2 tags to h3, h4, or refrain from using any heading tags.

    Could you add an option to change the tags around the table titles?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    thanks for your post, and sorry for the trouble.

    For this, you can use a little bit of PHP code e.g. in your theme’s “functions.php” file. Please see https://wordpress.org/support/topic/use-h3-instead-of-h2/#post-8481159

    Regards,
    Tobias

    Thread Starter msilvertant

    (@msilvertant)

    Thanks! What do I do if I want to turn h2 tags into h5 though?

    Having the option to change this within the plugin would still be a very welcome feature. As well as the option to surround the tables with divs; I would have preferred not to have to install an additional plugin for that.

    Thread Starter msilvertant

    (@msilvertant)

    Update:

    I used the following which worked like a charm:

    add_filter( 'tablepress_print_name_html_tag', 'heymrdj27_tablepress_change_table_name_h2_to_h3', 10, 2 );
    function heymrdj27_tablepress_change_table_name_h2_to_h3( $tag, $table_id ) {
      $tag = 'h5';
      return $tag;
    }
    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    Indeed, for h5 tags, you would just change that one line in the code.

    I don’t have plans to add this as an option in the user interface. It’s such a rarely done change that it would just confuse new and inexperienced users with another option (that then also would have to include technical language). I therefore like to stick with WordPress’ mantra of “Decisions, not Options.”.

    And what do you mean with “additional plugin”? This extra code in your theme’s “functions.php” will not have any influence on the site’s performance.

    Regards,
    Tobias

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.