• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
Klong Designs

Klong Designs

Wordpress Designer, Developer and Web Programmer

  • Home
  • About
  • Services
    • WordPress
      • Theme Design
      • Plugin Tweaks
      • Site Migrations
    • Graphic Design
    • Custom Programming
      • Responsive Design
    • SEO
  • Articles
    • Facebook
    • HTML
    • jQuery
    • PHP
    • WordPress
  • Contact/Quote Request

WordPress – bloginfo vs get_xxx_directory_uri

November 1, 2013 By Chris Klongpayabal 1 Comment

When I first started using WordPress, I found out about the bloginfo function, which gives you a lot of information about your blog. Normally I would use it to denote things like the site name (bloginfo(‘name’)), the blog description (bloginfo(‘description’)), and even to link to my scripts (bloginfo(‘template_directory’)).

I found out late about the functions get_template_directory_uri() and get_stylesheet_directory_uri().  What I couldn’t wrap my head around was which one was better to use. These new functions did the same as bloginfo(‘template_directory’) and bloginfo(‘stylesheet_directory’), so why should I use the other longer one?  I decided that I didn’t want to use these new codes because the usage I had decided to go with was working.

However, the design industry only grows as new technology is adopted. So I decided I would try to figure out which of these is better.  In my study, I’ve found that using get_template_directory_uri() and get_stylesheet_directory_uri() is better than using bloginfo for one good reason.  bloginfo(‘template_directory’) will not check for SSL. So even if you are on a secure page (like a checkout page), bloginfo will return http:// version.  This means that in some browsers, your stylesheets will not load, and you’ll have a broken site.

get_xxx_directory_uri() checks for SSL and will return the correct beginning to your URL (either http:// or https://).  So now that we know which function set works better, how do we decide which one to use:

get_template_directory_uri() and get_stylesheet_directory_uri() will return the same thing if you are not using a child theme. If you are using a child theme, get_template_directory_uri() will return the page to the parent theme folder, while get_stylesheet_diretory_uri() will retun the child theme folder.

Reader Interactions

Trackbacks

  1. Adding a Custom Javascript or jQuery Script Files to WordPress Theme or Child Theme | bigTreeWeb says:
    February 19, 2014 at 5:22 am

    […] get_stylsheet_directory_uri () says this is a file in the Child Theme directory, or where the file is located in relationship to the parent or child theme. If this were a parent theme you would use get_template_directory_uri(). Some people have suggested using get_bloginfo (‘stylesheet_directory’) instead. However I read an article to see what the difference was and decided not to do it that way, even though it worked (see page at this link for reference: http://www.klongdesigns.com/wordpress-bloginfo-vs-get_xxx_directory_uri/). […]

    Reply

Leave a Reply Cancel reply

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

Primary Sidebar

Quick Quote

Footer

Services

Graphic Design - This includes (but is not limited to) logos, banners, signs, posters, business cards, rack cards, brochures, flyers, and postcards.
Website Design - This includes (but is not limited to) theme design, logo design, banner ads, post graphics, pinterest-based images, image maps and navigation design.
Website Programming - This includes (but is not limited to) HTML, CSS, Javascript, PHP, jQuery, SCSS and LESS, as well as MVC frameworks, Theme updates and tweaks, plugin updates and tweaks, Multisite setup, plugin design and customization.
SEO Work - This includes (but is not limited to) analytics review, site SEO review, video SEO, ongoing SEO updates, sitemap setup and goal tracking.
Maintenance Work - This includes (but is not limited to) Keeping WordPress up-to-date, running backups of your site and database, and answering any questions you have about your site.
If you would like more information, please fill out the quick quote form. Thanks!

Follow

A Few Client Sites

  • 5 Dollar Dinners
  • Get Rich Slowly
  • The Happy Housewife
  • I Save A2Z
  • Hip Homeschool Moms
  • Redefined Mom
  • Queen Bee Coupons
  • More with Less Today
  • Saving Advice
  • One Crazy Mom

Copyright © 2023 · Klong Designs