04init 添加javasscrupt 連結


define ('DIGGTHIS_JS',
<%%KEEPWHITESPACE%%>	"&lt;script type='text/javascript'&gt;
<%%KEEPWHITESPACE%%>		(function() {
<%%KEEPWHITESPACE%%>		var s = document.createElement('SCRIPT'), s1 = document.getElementsByTagName('SCRIPT')[0];
<%%KEEPWHITESPACE%%>		s.type = 'text/javascript';
<%%KEEPWHITESPACE%%>		s.async = true;
<%%KEEPWHITESPACE%%>		s.src = 'http://widgets.digg.com/buttons.js';
<%%KEEPWHITESPACE%%>		s1.parentNode.insertBefore(s, s1);
<%%KEEPWHITESPACE%%>		})();
<%%KEEPWHITESPACE%%>	&lt;/script&gt;");

function diggthis_add_js_to_doc_head() {
<%%KEEPWHITESPACE%%>	print DIGGTHIS_JS;
}

add_action('init','diggthis_add_js_to_doc_head');

方法2

add_action( 'wp_enqueue_scripts', 'add_my_script' );
function add_my_script() {
<%%KEEPWHITESPACE%%> wp_enqueue_script(
<%%KEEPWHITESPACE%%> 'your-script', // name your script so that you can attach other scripts and de-register, etc.
<%%KEEPWHITESPACE%%> get_template_directory_uri() . '/js/your-script.js', // this is the location of your script file
<%%KEEPWHITESPACE%%> array('jquery') // this array lists the scripts upon which your script depends
<%%KEEPWHITESPACE%%> );
}

wordpress
CH02用戶資料CH03基本APICH05 分類頁面Category.phpCH09Screen Options(顯示選項)CH10外掛pluginsCH11 add_actionCH12 add_filterCH13Meta Box(自訂區塊)CH14widget(自訂模組)CH15 DBCH16AJAXCH17ShortcodeCH20 wordpress muCH30WooCommerce