<?xml version="1.0" encoding="UTF-8"?><rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
> <channel><title>Comments on: Smartly resolving your WordPress pages and posts JavaScript and CSS dependences</title> <atom:link href="http://www.heavyworks.net/blog/posts/smartly-resolving-your-wordpress-pages-and-posts-javascript-and-css-dependences/feed" rel="self" type="application/rss+xml" /><link>http://www.heavyworks.net/blog/posts/smartly-resolving-your-wordpress-pages-and-posts-javascript-and-css-dependences</link> <description>Extreme Software Engineering</description> <lastBuildDate>Thu, 09 Feb 2012 06:29:07 +0000</lastBuildDate> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3</generator> <item><title>By: tkaranov</title><link>http://www.heavyworks.net/blog/posts/smartly-resolving-your-wordpress-pages-and-posts-javascript-and-css-dependences/comment-page-1#comment-566</link> <dc:creator>tkaranov</dc:creator> <pubDate>Sat, 24 Dec 2011 15:28:46 +0000</pubDate> <guid
isPermaLink="false">http://www.heavyworks.net/?p=401#comment-566</guid> <description>I have similar code that takes the js file name from the custom field value:
if ( get_post_meta($post-&gt;ID, &#039;javascript&#039;, true) ) {
$script = get_post_meta($post-&gt;ID, &#039;javascript&#039;, true);
$script_path = get_bloginfo(&#039;template_url&#039;) . &#039;/scripts/&#039; . $script . &#039;.js&#039;;
wp_enqueue_script( $script, $script_path );
}
The code above is in my header.php and each post that needs custom javascript has a custom field named javascript with a value = to the js file name.
However, it only works when the post is viewed as a single post or is the first post on the home page.  Once another post is added (making the relevant post now the 2nd post on the home page) this code doesn&#039;t work.
It sounds like the use of &quot;foreach&quot; instead of &quot;if&quot; is the difference but  don&#039;t know enough to change the code to a &quot;foreach&quot; statement instead of an &quot;if&quot; statement.
Would you please advise how I can change this code to work as a &quot;foreach&quot; statement?</description> <content:encoded><![CDATA[<p>I have similar code that takes the js file name from the custom field value:<br
/> if ( get_post_meta($post-&gt;ID, &#8216;javascript&#8217;, true) ) {<br
/> $script = get_post_meta($post-&gt;ID, &#8216;javascript&#8217;, true);</p><p> $script_path = get_bloginfo(&#8216;template_url&#8217;) . &#8216;/scripts/&#8217; . $script . &#8216;.js&#8217;;<br
/> wp_enqueue_script( $script, $script_path );<br
/> }<br
/> The code above is in my header.php and each post that needs custom javascript has a custom field named javascript with a value = to the js file name.</p><p>However, it only works when the post is viewed as a single post or is the first post on the home page.  Once another post is added (making the relevant post now the 2nd post on the home page) this code doesn&#8217;t work.</p><p>It sounds like the use of &#8220;foreach&#8221; instead of &#8220;if&#8221; is the difference but  don&#8217;t know enough to change the code to a &#8220;foreach&#8221; statement instead of an &#8220;if&#8221; statement.</p><p>Would you please advise how I can change this code to work as a &#8220;foreach&#8221; statement?</p> ]]></content:encoded> </item> <item><title>By: Hessy</title><link>http://www.heavyworks.net/blog/posts/smartly-resolving-your-wordpress-pages-and-posts-javascript-and-css-dependences/comment-page-1#comment-533</link> <dc:creator>Hessy</dc:creator> <pubDate>Tue, 12 Apr 2011 02:04:58 +0000</pubDate> <guid
isPermaLink="false">http://www.heavyworks.net/?p=401#comment-533</guid> <description>Good point. I hadn&#039;t tohguth about it quite that way. :)</description> <content:encoded><![CDATA[<p>Good point. I hadn&#8217;t tohguth about it quite that way. :)</p> ]]></content:encoded> </item> <item><title>By: Teige</title><link>http://www.heavyworks.net/blog/posts/smartly-resolving-your-wordpress-pages-and-posts-javascript-and-css-dependences/comment-page-1#comment-528</link> <dc:creator>Teige</dc:creator> <pubDate>Mon, 11 Apr 2011 23:19:23 +0000</pubDate> <guid
isPermaLink="false">http://www.heavyworks.net/?p=401#comment-528</guid> <description>IMHO you&#039;ve got the right aneswr!</description> <content:encoded><![CDATA[<p><acronym
title="In my humble opinion">IMHO</acronym> you&#8217;ve got the right aneswr!</p> ]]></content:encoded> </item> <item><title>By: Jan Seidl</title><link>http://www.heavyworks.net/blog/posts/smartly-resolving-your-wordpress-pages-and-posts-javascript-and-css-dependences/comment-page-1#comment-306</link> <dc:creator>Jan Seidl</dc:creator> <pubDate>Wed, 24 Feb 2010 02:43:51 +0000</pubDate> <guid
isPermaLink="false">http://www.heavyworks.net/?p=401#comment-306</guid> <description>That&#039;s a nice idea Bruno! Will test it out and update the post! Thanks for the tip!</description> <content:encoded><![CDATA[<p>That&#8217;s a nice idea Bruno! Will test it out and update the post! Thanks for the tip!</p> ]]></content:encoded> </item> <item><title>By: Bruno Lustosa</title><link>http://www.heavyworks.net/blog/posts/smartly-resolving-your-wordpress-pages-and-posts-javascript-and-css-dependences/comment-page-1#comment-305</link> <dc:creator>Bruno Lustosa</dc:creator> <pubDate>Wed, 24 Feb 2010 00:33:49 +0000</pubDate> <guid
isPermaLink="false">http://www.heavyworks.net/?p=401#comment-305</guid> <description>Very fine article. Using custom fields to store javascript and stylesheet info is very clever.
Perhaps it could be made better by hooking to wp_head and placing both foreachs in functions.php. This would leave the template file with less kludge.</description> <content:encoded><![CDATA[<p>Very fine article. Using custom fields to store javascript and stylesheet info is very clever.<br
/> Perhaps it could be made better by hooking to wp_head and placing both foreachs in functions.php. This would leave the template file with less kludge.</p> ]]></content:encoded> </item> </channel> </rss>
