Note that there are some explanatory texts on larger screens.

plurals
  1. POcount() causing "unexpected T_STRING" error?
    text
    copied!<p>I'm trying to define a new shortcode in WordPress, and I get the following error when the function is loaded (just loaded, I haven't tried to call it anywhere yet): </p> <pre><code>Parse error: syntax error, unexpected T_STRING in /pathtomytheme/user_functions.php on line 105 </code></pre> <p>Here's the code; line 105 is "$cat_n = count($cats) – 1;":</p> <pre><code>function usertag_2colcats($atts) { extract(shortcode_atts(array('parent' =&gt; 0,'depth' =&gt; 2,), $atts)); $cats = explode('&lt;br /&gt;', wp_list_categories('title_li=&amp;echo=0&amp;depth=' . $depth . '&amp;style=none&amp;show_count=1&amp;use_desc_for_title=0&amp;child_of=' . $parent)); $cat_n = count($cats) – 1; for ($i = 0; $i &lt; $cat_n; $i++) { if ($i &lt; $cat_n/2) $cat_left = $cat_left . '&lt;li&gt;' . $cats[$i] . '&lt;/li&gt;'; elseif ($i &gt;= $cat_n/2) $cat_right = $cat_right.'&lt;li&gt;'.$cats[$i].'&lt;/li&gt;'; } echo '&lt;ul class="leftcats"&gt;' . $cat_left . '&lt;/ul&gt;&lt;ul class="rightcats"&gt;' . $cat_right . '&lt;/ul&gt;'; </code></pre> <p>}</p> <p>If I change that line so that it doesn't use the count function, e.g. to "$cat_n = 5;", the function loads without error. It seems like I'm missing something really obvious; what is it?</p> <p>The original code is here: <a href="http://pcsplace.com/blog-tips/how-to-split-categories-list-into-columns-in-wordpress/" rel="nofollow noreferrer">http://pcsplace.com/blog-tips/how-to-split-categories-list-into-columns-in-wordpress/</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload