Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript Introduction to jQuery Hello, jQuery! Why jQuery?

Tracey Wright
Tracey Wright
10,746 Points

Jquery/Javascript and Wordpress

Hi, DOes anyone know of any great tuts about how to start customizing a wordpress bult site, using javascript/Jquery?

Sam Baines
Sam Baines
4,315 Points

Maybe check out the wordpress courses or track on treehouse.

1 Answer

Jacob Herrington
Jacob Herrington
15,835 Points

You can try the WordPress Development track here, but JavaScript should function the same way on a WordPress page as it does on any other web page. Practicing the Front End Dev courses or going head first into the Fullstack Javascript track will teach you enough to accomplish what you want to implement.

For example in a WordPress document:

<?php
/**
 * The main template file.
 *
 * This is the most generic template file in a WordPress theme
 * and one of the two required files for a theme (the other being style.css).
 * It is used to display a page when nothing more specific matches a query.
 * E.g., it puts together the home page when no home.php file exists.
 * Learn more: http://codex.wordpress.org/Template_Hierarchy
 *
 * @package WordPress
 * @subpackage themename
 */
get_header(); ?>

<script>
  alert("I'm a JavaScript");
</script>

<h3>This is the core page (index.php):</h3>

<?php while(have_posts()) : the_post(); ?>

    title: <?php the_title(); ?><br />
    ID: <?php the_ID(); ?><br />
    time: <?php the_time(get_option('date_format')); ?><br />
    excerpt: <?php the_excerpt(); ?><br />
    link: <a href="<?php the_permalink(); ?>">link</a><br />
    <hr />

<?php endwhile; ?>

<?php get_footer(); ?>

If you read that PHP code (specifically builds a really basic WordPress homepage) you might notice a <script> tag. Inside I wrote some JavaScript, that would execute on any webpage regardless of whether or not it was a part of a WordPress site.