Support » Plugin: TablePress - Tables in WordPress made easy » Hiding [Table id=#] in Index Page

  • Resolved Goodvalley

    (@goodvalley)


    Hi Tobias,

    On my theme’s main page I can see a snippet of my posts sorted by Category. It shows the first words of the last posts.

    The problem is that some of these posts begin with a table, and the snippet in the main page is showing [Table id=#] and then the first words of my text.

    Is there any way to hide the code for these snippets?

    The website is http://www.drumscult.com

    Thanks very much,
    Carles

    http://wordpress.org/plugins/tablepress/

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

    (@tobiasbg)

    Hi,

    thanks for your post, and sorry for the trouble.

    Most likely, this is caused by your theme only extracting the first part of each post without either evaluating Shortcodes (which you don’t want here, as it would show the tables there) or stripping the Shortcodes. This is possible with the WordPress strip_shortcodes() function.
    You could either directly modify the corresponding theme template file and add this, or ask your theme’s developer to maybe incorporate that into the theme in general.

    Regards,
    Tobias

    Thread Starter Goodvalley

    (@goodvalley)

    Yes, I’ve tried that but nothing happens.

    Those snippets are generated by another .php file, I’ve tried to put the code there but nope…

    I tried the code on style.css and functions.php and nothing…

    However, I’ve found some tricky way, it consists in telling the code to start showing the content from character #xxx instead of from the first character of the content. But I don’t think it’s a good solution.

    Maybe I’m doing something wrong with the strip_shortcodes() function.

    I write it like this:

    function remove_shortcode_from_index($content) {
      if ( is_home() ) {
        $content = strip_shortcodes( $content );
      }
      return $content;
    }
    add_filter('the_content', 'remove_shortcode_from_index');

    Anyway, thanks very much Tobias

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    using this on the the_content is probably why it’s not working.
    You might want to apply this on the_excerpt.

    Showing the content starting with character #xx will fail on posts that don’t have a Shortcode at the beginning, of if your Shortcodes later contain more parameters.

    Regards,
    Tobias

    Thread Starter Goodvalley

    (@goodvalley)

    Hi Tobias,

    I put this at the end of my style.css but nothing happened:

    function remove_shortcode_from_index($excerpt) {
      if ( is_home() ) {
        $excerpt = strip_shortcodes( $excerpt );
      }
      return $excerpt;
    }
    add_filter('the_excerpt', 'remove_shortcode_from_index');

    I’m sure I’m writting something wrong, I’ve tried changing some things but it won’t work.

    Thread Starter Goodvalley

    (@goodvalley)

    Hi Tobias,

    I think I’ve solved it. I’ll tell you what I did for if someone asks the same questions:

    My theme has 5 feat_cat#.php (1,2,3,4 and 5). In their code, I saw a line that said:

    $content = strip_tags($content);

    So I knew my code should go there.

    I simply put one line of code below that line in each one of the 5 pages:

    $content = strip_shortcodes( $content );

    For now, it’s working fine, so I think that’s the best solution.

    Thanks very much for the hints. Your plugin is really awesome. Take care,
    Carles

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    the code is PHP code, so adding it to the style.css is wrong. You would need to add it to the “functions.php”.

    However, adding it to the feat_cat#.php files is also ok. Great to hear that you found this 🙂
    Just don’t forget that these changes will be lost after a theme update, so you’ll have to re-apply them then.

    Best wishes,
    Tobias

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

    Thread Starter Goodvalley

    (@goodvalley)

    I havd done it before, 5 stars of course.

    Thanks for the quick answers and the hints to the code!

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    thanks, I really appreciate that! 🙂

    Regards,
    Tobias

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Hiding [Table id=#] in Index Page’ is closed to new replies.