• Skip to main content
  • Skip to primary sidebar
  • Business
  • WordPress
  • Security
  • Marketing
  • Publicity
  • Computing
  • Resources
  • Whatevs

Purely Wordpress

Just The Tech, News, and Info We Deem To Post

  • Home
  • About
  • Contact
  • Contribute
You are here: Home / Code Snippets / Generate Path to WordPress Root

Generate Path to WordPress Root

Screenshot of WordPress plugin php and html code

Use the following codes to generate a path to the WordPress root URL in theme and template files.

/** Use the get option to pull your domain name  */
<?php echo get_option('home'); ?>

/** When inserted into an A or IMG tag writes the domain name */
<img src="<?php echo get_option('home'); ?>/images/filename.jpg">

/** Use the get option to pull your domain name */
<?php get_bloginfo('stylesheet_directory').'/images'; ?>

/** WWhen inserted into an A or IMG tag writes the path to your themes directory in wordpress */
<?php get_bloginfo('stylesheet_directory').'/images'; ?>

by Jack Alltrade on August 5, 2014

Filed Under: Code Snippets, WordPress Core Tagged With: Code, Layout, Template File, WP Core

Reader Interactions

Share Your Two Cents Cancel reply

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

Primary Sidebar

Categories

  • Code Snippets
  • Development
  • File Management
  • Genesis Framework
  • Hosting
  • Legacy
  • Plugins
  • SEO
  • Tech Terms
  • Themes
  • User Experience
  • User Interface
  • WordPress Core
  • WordPress Functionality

Warning! Use at your own risk!

As always, use at your own risk and remember to backup your site prior to inserting new code.

© Copyright Jack Alltrade & Associates 2025 · Purely Supplemental™ is a trademark of Jack Alltrade & Associates