{"id":13346373,"date":"2020-09-01T17:48:05","date_gmt":"2020-09-01T17:48:05","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/parameter-passing\/"},"modified":"2020-09-01T17:48:05","modified_gmt":"2020-09-01T17:48:05","slug":"parameter-passing","status":"publish","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/parameter-passing\/","title":{"rendered":"Parameter passing"},"content":{"rendered":"<p>Hi,<br \/>\nI followed the other posting instructions re parameter passing with the following code snipett<\/p>\n<p>add_shortcode( &#8216;introduction&#8217;, function($atts){<\/p>\n<p>\t$locn = $atts[&#8220;locn&#8221;];<br \/>\n\t$output = &#8220;&#8221;;<br \/>\n\t$output .= &#8216;&lt;h1&gt;Assessment Planner &#8211; &#8216;.$locn.'&lt;\/h1&gt;&#8217;;<br \/>\n\t$output .= &#8216;&lt;table id=&#8221;chance&#8221;&gt;&lt;tr&gt;&lt;td style=&#8221;width: 12%&#8221;&gt;% Chance:&lt;\/td&gt;&lt;td&gt;&lt;span id=&#8221;legendContainer&#8221; class=&#8221;legend&#8221; style=&#8221;border-style: solid; border-color: threedface; width: 100%&#8221;&gt; &lt;\/span&gt;&lt;\/td&gt;&lt;\/tr&gt;&lt;\/table&gt;&#8217;;<\/p>\n<p>\treturn $output;<br \/>\n});http:\/\/localhost\/risk\/wp-admin\/edit.php?post_type=page<\/p>\n<p>and get the following error report<\/p>\n<p>Warning: Illegal string offset &#8216;locn&#8217; in H:\\sites.web\\risk\\wp-content\\plugins\\code-snippets\\php\\snippet-ops.php(446) : eval()&#8217;d code on line 3<br \/>\nCall Stack<br \/>\n#\tTime\tMemory\tFunction\tLocation<br \/>\n1\t0.0002\t410016\t{main}( )\t&#8230;\\index.php:0<br \/>\n2\t0.0005\t410288\trequire( &#8216;H:\\sites.web\\risk\\wp-blog-header.php&#8217; )\t&#8230;\\index.php:17<br \/>\n3\t0.1488\t5806184\trequire_once( &#8216;H:\\sites.web\\risk\\wp-includes\\template-loader.php&#8217; )\t&#8230;\\wp-blog-header.php:19<br \/>\n4\t0.1573\t5894984\tinclude( &#8216;H:\\sites.web\\risk\\wp-content\\themes\\catch-kathmandu-pro\\page.php&#8217; )\t&#8230;\\template-loader.php:106<br \/>\n5\t0.2095\t6080256\tget_template_part( )\t&#8230;\\page.php:22<br \/>\n6\t0.2096\t6086408\tlocate_template( )\t&#8230;\\general-template.php:204<br \/>\n7\t0.2576\t6086520\tload_template( )\t&#8230;\\template.php:676<br \/>\n8\t0.2577\t6086856\trequire( &#8216;H:\\sites.web\\risk\\wp-content\\themes\\catch-kathmandu-pro\\content-page.php&#8217; )\t&#8230;\\template.php:732<br \/>\n9\t0.2599\t6153896\tthe_content( )\t&#8230;\\content-page.php:25<br \/>\n10\t0.2601\t6153920\tapply_filters( )\t&#8230;\\post-template.php:253<br \/>\n11\t0.2601\t6154320\tWP_Hook-&gt;apply_filters( )\t&#8230;\\plugin.php:206<br \/>\n12\t0.2609\t6157080\tdo_shortcode( )\t&#8230;\\class-wp-hook.php:287<br \/>\n13\t0.2609\t6159408\tpreg_replace_callback ( )\t&#8230;\\shortcodes.php:218<br \/>\n14\t0.2609\t6160024\tdo_shortcode_tag( )\t&#8230;\\shortcodes.php:218<br \/>\n15\t0.2610\t6160024\t{closure:H:\\sites.web\\risk\\wp-content\\plugins\\code-snippets\\php\\snippet-ops.php(446) : eval()&#8217;d code:1-9}( )\t&#8230;\\shortcodes.php:343<\/p>\n<p>The shortccode on the page is <\/p>\n<p>[introduction locn=&#8221;UNITED KINGDOM&#8221;]<\/p>\n<p>It works fine without reference to $atts[&#8220;locn&#8221;] in line 3 and $locn in line 5 <\/p>\n<p>Any suggestions?<\/p>\n<p>Thanks<\/p>\n<p>Paul<\/p>\n","protected":false},"template":"","class_list":["post-13346373","topic","type-topic","status-publish","hentry"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/13346373","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/13346373\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=13346373"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}