How to link to a JavaScript file in your BuddyPress child theme
Sep 06 2010 - 1 MINS READ

You might want to link to a JavaScript file in your child theme’s directory. You could always hard-code a link to the file, but then if you ever change the name of the theme the link won’t work anymore. It’s better to use a PHP function to automatically call the main child theme’s directory. Unfortunately the normal PHP functions for doing this will always call your BuddyPress Default theme, located in wp-content/plugins/bp-themes/bp-default. Here’s the solution to the problem.

This function will call the root directory of your BuddyPress child theme.

If you are adding a JavaScript file, you should put the file into the following directory: yourtheme/_inc/js/. You will likely need to create the “js” directory. Then call this file using:


<script src="<?php bloginfo(‘stylesheet_directory’); ?>" type="text/javascript">// <![CDATA[
/_inc/js/file.js">
// ]]></script>

Need help with your BuddyPress theme?

Contact us today. We’ll be happy to help.