WordPress.org

Ready to get started?Download WordPress

Forums

WP-Table Reloaded
[resolved] WP-Table-Reloaded doesn't work with do_shortcode() (7 posts)

  1. Mikko Saari
    Member
    Posted 3 years ago #

    Hi!

    I'm using WP-Table-Reloaded 1.8.1 with WordPress 3.0.5. It works fantastically and is one of the most important plugins for us. Thanks a lot, it sure is amazing work.

    I'm having a problem with it, though. I'm doing a plugin that analyzes the posts in the database and I'd like to expand the tables to see what they print out. However, if I pass $post->post_content to do_shortcode(), tables are not expanded.

    The same happens if I call the table directly: do_shortcode('[table id=62]'); - this just prints out the tag.

    How could I get the tables to expand, and why aren't they expanding like they should?

  2. TobiasBg
    Member
    Plugin Author

    Posted 3 years ago #

    Hi,

    if your call to do_shortcode('[table id=62]'); only results in [table id=62], this means that the Shortcode is not yet registered, likely, because you are doing your call to early or something like that.

    Where and how are you calling do_shortcode()? Can you provide a longer snippet of code? Why don't you use the template tag the_content()?
    And instead of do_shortcode('[table id=62]'); you could actually just use WP-Table Reloaded's own template tag, like wp_table_reloaded_print_table( "id=62" ); (see http://tobias.baethge.com/wordpress-plugins/wp-table-reloaded-english/documentation/ for more on that).

    Regards,
    Tobias

  3. Mikko Saari
    Member
    Posted 3 years ago #

    I'm not printing the data out, that's the thing, but putting it in a variable. The whole thing is in a plugin and run when I'm looking at the plugin admin menu.

    I'm trying to do some SEO analysis and search the posts to find out posts that are missing links and images, and I need to find the links and images that are in tables.

    Looks like I need to dig out the table id then and use wp_table_reloaded_get_table(). That should do the trick. Thanks!

  4. Mikko Saari
    Member
    Posted 3 years ago #

    Yeah, except the function isn't defined either. I'm guessing the problem is that I'm doing this on the admin side.

  5. TobiasBg
    Member
    Plugin Author

    Posted 3 years ago #

    Hi,

    thanks for your clarification!

    Yes, exactly, those functions are not available on the admin side (because the plugin itself never needs them there).
    You could however simply load your own instance of the plugin frontend part in your plugin:

    include_once  ( WP_TABLE_RELOADED_ABSPATH . 'controllers/controller-frontend.php' );
    $My_WP_Table_Reloaded = new WP_Table_Reloaded_Controller_Frontend();

    After that, the Shortcodes should be available (as they are registered in the frontend class's constructor), or you could directly perform a query:

    $atts = array( 'id' => 62 );
    $table_output = $My_WP_Table_Reloadedd->handle_content_shortcode_table( $atts );

    Hope this helps!

    Best wishes,
    Tobias

  6. Mikko Saari
    Member
    Posted 3 years ago #

    Thanks, this sorted out the problem. I figured out the include, but not triggering the constructor.

    As I said, excellent plugin, and top-notch support too!

  7. TobiasBg
    Member
    Plugin Author

    Posted 3 years ago #

    Hi,

    great! :-) Good to your that you got this to work!

    Best wishes,
    Tobias

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic