• Resolved m.songbird

    (@msongbird-1)


    Hi,
    I am on the Genesis theme, which does not allow shortcode on category pages.

    I found this code to make it happen anyway:

    add_action(‘genesis_before_post’, ‘gravity_form_before_content‘);
    function gravity_form_before_content() {
    if (is_category()) {
    echo do_shortcode(‘[gravityform id=1 title=false description=false ajax=true]’);
    }
    }

    except of course I need to replace the gravity form calls with table press calls, so my shortcode will work.

    PHP coding is out of my league so I couldn’t figure out which functions to use.

    Can you help?

    Thanks. Marianne

    https://www.ads-software.com/plugins/tablepress/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Tobias B?thge

    (@tobiasbg)

    Hi,

    thanks for your post, and sorry for the trouble.

    From what I can see, you will simply have to change those function names to something unique and the Shortcode as well, e.g.

    add_action( 'genesis_before_post', 'marianne_genesis_tablepress_shortcode' );
    function marianne_genesis_tablepress_shortcode() {
      if ( is_category() ) {
        echo do_shortcode( '[table id=123 /]' );
      }
    }

    Regards,
    Tobias

    Thread Starter m.songbird

    (@msongbird-1)

    Thanks for your quick reply.
    Wouldn’t have thought the solution could be that simple.

    Except it doesn’t work (insert sad face).

    The short code is still not working on my category page. It just show the actual short code text [table id=1 /]

    Guess you have no insights on Genesis?

    Plugin Author Tobias B?thge

    (@tobiasbg)

    Hi,

    no, sorry, I’m not familiar at all with Genesis.

    It’s strange that this would not work on a category page though, I don’t really see why…

    Maybe using the TablePress template tag functions work, e.g.

    add_action( 'genesis_before_post', 'marianne_genesis_tablepress_shortcode' );
    function marianne_genesis_tablepress_shortcode() {
      if ( is_category() ) {
        tablepress_print_table( array(
          'id' => '123',
        ) );
      }
    }

    Regards,
    Tobias

    Thread Starter m.songbird

    (@msongbird-1)

    Thank for trying.
    But this doesn’t work either.

    I have asked for support on the genesis forum too. Maybe someone there will have an idea.

    For my understanding in your code what does the 123 stand for? Is that an actual number? Like would this render only a table with id-123 or does it render a table with any id?

    Plugin Author Tobias B?thge

    (@tobiasbg)

    Hi,

    that 123 is an example for a table ID. You’d have to change this number to the ID of the table that you want to display.

    I don’t know why the tables are still not showing though, sorry ?? Are they working fine in regular posts/pages on your site?

    Regards,
    Tobias

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Adding shortcake on category page’ is closed to new replies.