Path to files in WordPress

Adding javascript and css files:

<link href="<?php bloginfo('stylesheet_directory'); ?>/css/style.css" rel="stylesheet" />
<script src="<?php bloginfo('stylesheet_directory'); ?>/js/script.js"></script>

Other functions for getting path to files in WordPress or bloginfo variables or bloginfo.

If we don't have parent-child theme scheme than all constants based on parent-child scheme will return the same values.

Parent theme path: http://site.com/wp-content/themes/parent

<?php
echo get_template_directory_uri();
// or
echo get_bloginfo('template_directory');
?>

Child theme path: http://site.com/wp-content/themes/child

<?php
echo get_stylesheet_directory_uri();
// or
echo get_bloginfo('stylesheet_directory');
?>

Absolute parent theme path: D:/site/wp-content/themes/parent

<?php
echo get_template_directory();
// or
echo TEMPLATEPATH;
?>

Absolute child theme path: D:/site/wp-content/themes/child

<?php
echo get_stylesheet_directory();
// or
echo STYLESHEETPATH;
?>

Path to plugins dir: D:/site/wp-content/plugins

<?php
echo WP_PLUGIN_DIR;
?>

Absolute path to plugins dir: http://site.com/wp-content/plugins

<?php
echo WP_PLUGIN_URL;
?>

Admin link: http://site.com/wp-admin/plugin.php

<?php admin_url('plugins.php'); ?>

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">