Hi guys,
I'm a noob in programming and thematic, so please bear with me if I ask something stupid :P
I am trying to make a tab navigation on a custom page template, and am following this tutorial http://justintadlock.com/archives/2007/11/07/how-to-create-tabs-using-jquery.
According to the tutorial, I should inject 2 Javascripts file to the header. I googled around, searching this forum and following the wiki guide, but somehow I just couldn't make the tab works. I've tried it using another theme, a blank one, where I can just hardcoded the scripts into the header, and it works.
One of the method (I've tried a lot) I used was from Ian himself, found it on this forum, where he demonstrated (and I copy pasted it) injecting a JS file to the header so everytime the header loaded the user gets a message "Hello thematic user" or something like that (works, although of course, not what I want). Since I want this tab to display only on a custom page (homepage) I try to combine it with a conditional "if".
Here are two of my codes (I was / am experimenting with plenty of codes :P):
<?php
function ruby_jqueried_scripts() {
if (is_page('5')){?>
<script type="text/javascript" src="<?php echo bloginfo(stylesheet_directory) .'/jquery.js'; ?>"></script>
<?php }}
add_action('thematic_head_scripts','ruby_jqueried_scripts');
?>
<?php
function ruby_tabs_scripts() {
if (is_page('5')){?>
<script type="text/javascript" src="<?php echo bloginfo(stylesheet_directory) .'/tabs.js'; ?>"></script>
<?php }}
add_action('thematic_head_scripts','ruby_tabs_scripts');
?>
######
I was trying to use two separate functions, one for JQuery and one for "tabs.js"
######
And:
<?php
function ruby_tabs_scripts() {
if (is_page('5')){?>
<script type="text/javascript" src="<?php echo bloginfo(stylesheet_directory) .'/jquery.js'; ?>"></script>
<script type="text/javascript" src="<?php echo bloginfo(stylesheet_directory) .'/tabs.js'; ?>"></script>
<?php }}
add_action('thematic_head_scripts','ruby_tabs_scripts');
?>
####
Try to inject 2 scripts at once. Of course these were on two separate occasion.
####
More info:
- I am using this conditional-action (if - add_action) on CSS (custom CSS for homepage), and it works.
- I've checked all the paths, file names and also the code seems to be valid (no error message generated)
- Again, I tried this methods using a different theme and it works. I just copy-pasted the codes, except I just hardcoded the file directly into the header.
- I've also tried wp_enqueue_script(), and still not works.
So, help please :)
Oh, and another noob question. IIRC, wordpress has built-in JQuery, do we still need another copy in our js directory?
Thanks in advance!