399 posts
  • Has referred 100+ members
  • Has sold $250,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
+5 more
EugeneO says

I have shortcodes used to create styled tables:

[styled_table]

[styled_column] [/styled_column]

[styled_column] [/styled_column]

[styled_column] [/styled_column]

[/styled_table]

In the above example the table would be created with three columns.

The problem I’m having is that I need to automatically count the number of [styled_column] shortcodes inside the [styled_table] shortcode so that I can assign the table the correct width.

Does anyone know how I can do this?

221 posts
  • Has been part of the Envato Community for over 4 years
  • Has referred 1+ members
  • Has sold $1,000+ on Envato Market
  • Has collected 10+ items on Envato Market
+2 more
NuclearThemes says

Could you use an increment in the styled_columns function and then get it at the end with /style_table?

I’m only just coming across shortcodes so I’m not too sure whether that would work but it’s a thought.

399 posts
  • Has referred 100+ members
  • Has sold $250,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
+5 more
EugeneO says

I managed to get it to work using this:

$columns = substr_count( $content, '[styled_column' );

Note the front bracket “[” in the string it searches for so it distinguishes between [styled_column] and [/styled-column].

3503 posts
  • Elite Author: Sold more than $75,000 on Envato Market
  • Has sold $750,000+ on Envato Market
  • Located in United States
  • Helps us moderate the forums
+10 more
sevenspark Moderator says

Another way is to use Regular Expressions (I’ve done this for normal columns).

Helpful Information

  • Please read our community guidelines. Self promotion and discussion of piracy is not allowed.
  • Open a support ticket if you would like specific help with your account, deposits or purchases.
  • Item Support by authors is optional and may vary. Please see the Support tab on each item page.

Most of all, enjoy your time here. Thank you for being a valued Envato community member.

Post Reply

Format your entry with some basic HTML. Read the Full Details, or here is a refresher:

<strong></strong> to make things bold
<em></em> to emphasize
<ul><li> or <ol><li> to make lists
<h3> or <h4> to make headings
<pre></pre> for code blocks
<code></code> for a few words of code
<a></a> for links
<img> to paste in an image (it'll need to be hosted somewhere else though)
<blockquote></blockquote> to quote somebody

:grin: :shocked: :cry: Complete List of Smiley Codes

by
by
by
by
by
by