Jared Heinrichs

  • Technology Blog
  • Winnipeg Computer Repair
  • Winnipeg Photographer
  • Cooking With Jared
You are here: Home / Web Applications / Wordpress / Wordpress – How to use Wordpress settings in your theme

Sep 27, 2011 By Jared Heinrichs Leave a Comment

WordPress – How to use WordPress settings in your theme

One of the most powerful WordPress functions you will get to use is: bloginfo().

You can most likely tell that  WordPress’s bloginfo() function will return some information regarding your blog. I’ve listed all of the command you can feed bloginfo() below.

 

name                 = Testpilot
description          = Just another WordPress blog
admin_email          = admin@example

url                  = http://example/home
wpurl                = http://example/home/wp

stylesheet_directory = http://example/home/wp/wp-content/themes/child-theme
stylesheet_url       = http://example/home/wp/wp-content/themes/child-theme/style.css
template_directory   = http://example/home/wp/wp-content/themes/parent-theme
template_url         = http://example/home/wp/wp-content/themes/parent-theme

atom_url             = http://example/home/feed/atom
rss2_url             = http://example/home/feed
rss_url              = http://example/home/feed/rss
pingback_url         = http://example/home/wp/xmlrpc.php
rdf_url              = http://example/home/feed/rdf

comments_atom_url    = http://example/home/comments/feed/atom
comments_rss2_url    = http://example/home/comments/feed

charset              = UTF-8
html_type            = text/html
language             = en-US
text_direction       = ltr
version              = 3.1

I’m guessing since you are here you are wondering how can you use bloginfo() in your theme and why should you care?

The thing I tend to use bloginfo() for is making sure that no matter where on the site, things like my CSS file location, my home page and theme files are always calculated properly. One of the things I see most often with new WordPress users is that they use relative paths to files like CSS and images. While this might work in static sites, it doesn’t really work all that well in dynamically creates site like a WordPress Website.

Here’s an example:

image

Notice how I highlighted that the url has several sub folders – “/category/operating-system/active-directory-2003”. If your theme would have used relative paths for the logo and the encompassing link you would have noticed that the logo wouldn’t show up and then link would be most likely broken.

What I normally see people do to fix this issue is just put in Fully Qualified Paths for things like the logo and certain links. In my opinion not only does this add extra bloat to the website it also kind of defeats the dynamic nature of WordPress! Because I tend to create offline themes first and then move it to a online Webserver. If you didn’t use bloginfo() for the links you will have to do a bunch of extra manual changes where ever you hard coded things. This causes extra headaches and unneeded work.

Using my website as an example you can see I use bloginfo() to fill in the anchor link “Url”very easily. I’ve also told it display the Logo image that is located in the template directory.

image

Another thing I have seen is a person is wanting to make a slightly modified theme for say Christmas. If you were to copy the theme, rename the folder and activate then new theme,  all your hard coded links would no longer work or still point to the old theme location!

I recommend getting into a habit of making your themes with built in WordPress functions like bloginfo(). It will save you time and fustration. You will also know that you can pickup your theme and move it where ever you want and you don’t have to worry that the theme folder is even named the same.

Here’s a listing of ALL the settings you can use with “bloginfo()”. http://codex.wordpress.org/Function_Reference/bloginfo

Filed Under: Wordpress

Leave a Reply Cancel reply

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

Categories

  • Board Game Rules
  • Camera
  • Computer Hardware
    • Blackberry
    • drivers
    • iPad
    • Magic Jack
    • USB
  • Damn Small Linux
  • Exam Notes
  • Facebook
  • FREE Flashcards
  • Games
    • PC
      • League of Legends
    • Wii
    • xbox 360
  • Music
  • Networking
    • Cisco Certification
    • Mitel
    • Palo Alto Firewall
  • News
    • Google
    • Microsoft
  • Operating System
    • Active Directory (2003)
    • Android
    • Command Prompt
    • Damn Small Linux
    • Group Policy
    • Hyper-V
    • IIS
    • ISA 2006
    • Mac OS X
    • Microsoft Exchange Server
    • Powershell
    • Security
    • SME Server
    • Terminal Server 2003
    • Ubuntu Linux
      • Adito Web SSL VPN
      • OpenVpn-als
      • Webmin
    • Virtual Machine Manager
    • Windows 2003 SBS
    • Windows 2003 Server
    • Windows 2008
    • Windows 2008 R2
    • Windows 2012R2
    • Windows 7
    • Windows 8
    • Windows Command Line
    • Windows Deployment Services
    • Windows Server Backup
    • Windows Vista
    • Windows XP
  • Phones
  • Photography
  • Photos
    • Animals
    • Misc
    • Nature
    • Portraits
  • Portfolio
  • Programming
    • CSS
    • HTML
    • jQuery
    • MySQL
    • PHP
    • Script
  • Programs
    • Acrobat
    • Acrobat Reader
    • Adobe Dreamweaver
    • Adobe Illustrator
    • Adobe Photoshop
    • Anti-virus Software
    • Antivirus
    • Backup Exec
    • Bittorent
    • Blackberry BESADMIN
    • Internet Explorer 9
    • Lightroom
    • Microsoft Office
    • Netbeans
    • Onenote
    • Outlook
    • Shelby
    • Sysprep
    • Trend
    • Video Editing
    • Visual Studio
    • Windows Live Writer
    • WireShark
    • XP Mode
    • Zarafa
  • Recipe
  • Review
  • Software Links
  • Troubleshooting
  • Uncategorized
  • Videos
  • Web Applications
    • Brage
    • Google
    • Spiceworks
    • Wordpress
  • Web Browsers
    • Internet Explorer
  • Web Server
    • XAMPP
  • Winnipeg
    • ISP

Try searching this site!

Copyright © 2021 Winnipeg Web Design