Akhilesh Sharma
Akhilesh Sharma

Reputation: 1628

$("a[rel='example1']").colorbox is not a function

I am have integrated the colorbox jQuery Plugin into the Wordpress theme. But on the home page it displays $("a[rel='example1']").colorbox is not a function

but when I am running the code on the inner pages its working fine.

Please help

Link to the website: http://lab.pixzon.com/ca

Below is the code for the header file

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title><?php echo bloginfo('title');?></title>
<link rel="shortcut icon" href="<?php echo bloginfo('template_url')?>/images/icon.jpg"/>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="<?php echo bloginfo('stylesheet_url')?>" type="text/css" rel="stylesheet" />
<link media="screen" rel="stylesheet" href="<?php echo bloginfo('template_url')?>/css/colorbox.css" />
<script src="<?php echo bloginfo('template_url')?>/colorbox/jquery.min.js"></script>
<script type="text/javascript" src="<?php echo bloginfo('template_url')?>/js/browcss.js"></script>
<script src="<?php echo bloginfo('template_url')?>/colorbox/jquery.colorbox.js"></script>
<script language="javascript" type="text/javascript" src="<?php echo bloginfo('template_url')?>/js/site.js"></script>
<script language="JavaScript" src="<?php echo bloginfo('template_url')?>/js/swfobject.js"></script>
<?php 
wp_head();
?>

Upvotes: 1

Views: 6007

Answers (3)

Janzell Jurilla
Janzell Jurilla

Reputation: 1219

You can check you home page source:

Ex.

  1. View the page source of your home page site.
  2. Check if all dependencies of that code is included in the header / the code is either above to its dependencies. ex. One instance is jquery is not included in the home page. Are you using different javascript framework? if yes, then you need to put a Jquery no Conflict code.

Possible Reason:

One of the closest reason why is it not considered as a function because of dependencies missing.

Upvotes: 1

Triptan
Triptan

Reputation: 11

try to use jQuery in this form:

jQuery(document).ready(function(){
   jQuery("a[rel='example1']").colorbox
});

It should work.

Upvotes: 1

bestform
bestform

Reputation: 353

Your problem is, that you are loading two versions of jQuery.

What actually happens: you load the first jQuery, you then extend it with the Colorbox plugin and then you overwrite your first (extended) jQuery again. Just remove the last reference to jQuery and you should be good.

EDIT: looking at your code I suspect, that your wp_head(); call is adding the second reference.

EDIT2: On the home page, the jQuery script is being reloaded in the body (inside the poll div)

Upvotes: 5

Related Questions