W Discount synthroid No Rx, e bloggers have it rough. We live in a world full of more WordPress themes than you can shake a stick at, yet most of us are still tied to one old, worn out template. It's unfortunate, but let's be honest here—changing themes is a huge ordeal.
Generally speaking, whenever you opt for a new theme, you're going to have to do a fair amount of customization to get everything just right for your site. By the time you get to your third or fourth theme, you'll probably begin to grow a little weary of reinventing the wheel with each new design.
Fortunately, savvy users like you can solve this problem by creating a user-defined functions file that will work with any WordPress theme, Discount synthroid No Rx. The idea here is to place all of your common, customized design elements—like an author bio or a sales widget for your sidebar, for instance—within functions that reside in a separate, non-theme file. This serves a twofold purpose:
- First, because your common design tweaks are isolated in a non-theme file, you won't risk overwriting them whenever you change or upgrade your theme.
- Second, using a separate functions file creates a much more organized and less intimidating environment for customizing your theme. You can add and subtract HTML from your user-defined functions file without fear of "breaking" your theme, simply because you aren't trying to edit the theme files directly.
Before jumping into an example, I'd also like to point out that you can (and should) combine your user-defined functions file with a custom CSS stylesheet. Together, these two files act like a preferences panel for your site, allowing you to easily incorporate1 your most common changes into any WordPress theme. Discount synthroid No Rx, In the following example, you'll create your own user-defined functions file containing one sample function. Once you've done that, you'll use your new function in tandem with a custom stylesheet to output a del.icio.us bookmark link at the end of each post, clozapine No Prescription.
Step 1: Download Your User-defined Functions File
Your new functions file, user-functions.php, is just a normal PHP file that can be as simple or as complex as you like. Since we're going to be working with a common example today, I've gone ahead and created a sample user-functions.php file that you can download here. Please keep in mind that you can use this same file for your own user-defined functions in the future (with or without the example function).
Step 2: Write Your Own Function(s)
As I mentioned earlier, the goal of our example is to output a handy bookmarking link immediately after each post, Discount synthroid No Rx. Although our sample function is included in the user-functions.php download file, it warrants a more detailed explanation here. We'll start by taking a detailed look at the function, userfunc_bookmark_links():
function userfunc_bookmark_links() {
global $post;
?>
<?php
}
The first thing to note here is the function name. Intrinsically, it makes sense to give the function a simple name like bookmark_links(), but in order to ensure compatibility with all WordPress plugins and themes, it's best to add a consistent prefix to your own function names. Because all of these particular functions are user-defined, it makes sense to use something like userfunc for the prefix. Discount synthroid No Rx, From a coding standpoint, userfunc_bookmark_links() is extremely basic. It contains no interior logic, and the only thing the function actually does is output some HTML. Also, because this function pulls in the $post variable, it will only work when called from within the WordPress loop.
Most of your user-defined functions should end up looking and behaving like our sample function here. For practical purposes, you'll probably want to output custom HTML at various points throughout your theme, and you'll find that user-functions.php is a fantastic way to accomplish this.
Oh, and in case you were wondering, there is no limit to the number of functions you can define in your file, so be sure to go nuts with this, Discount synthroid No Rx. Zelnorm Dosage,
Step 3: Activating Your New Functions File
Once you've created your functions file, the next step is to activate it within your theme. Begin by uploading user-functions.php to your active theme folder. Next, open your theme's functions.php file for editing2, and then add the following line of code (you can place it anywhere):
include_once (TEMPLATEPATH . '/user-functions.php');
After editing your theme's functions.php file, simply save it and upload it back to your server. Discount synthroid No Rx, At this point, your user-defined functions will be available for use within your theme.
Step 4: How to Use Your New Functions
Although you've activated your new functions file, you won't notice any difference on your site until you actually call one of your functions from within a standard theme file.
In our example, the goal is to output a bookmarking link at the end of each post3. In order to do that, you'll need to open up your theme's single.php file, and locate the call to the following WordPress function:
<?php the_content(); ?>
As you might have guessed, the_content() outputs a fully-formatted blog post. Because our goal is to include bookmarking links after the post, it only makes sense to place the call to your new, user-defined function immediately after the call to the_content(). Here's how the code in single.php should look once you've inserted the call to userfunc_bookmark_links():
<?php
the_content();
userfunc_bookmark_links();
?>
If you've done everything correctly, when you visit a post's permalink page, you'll see that the post content is now followed by a clever little del.icio.us bookmark link, Discount synthroid No Rx.
Your next challenge is to style your new bookmarking links, and hopefully, you'll find this to be a simple and straightforward task. By default, the list has been given a class name of bookmark_links, and you can use that class in your custom stylesheet to target this set of links directly.
Bonus Styles for Thesis Users
Are you a Thesis Theme user. If so, Cheap xenical Overnight Delivery, then you'll want to try out this snippet of CSS on your site. Simply add the following declaration to your custom.css Discount synthroid No Rx, file, and boom—you'll get instant, em-based goodness:
.custom ul.bookmark_links {
list-style: none;
margin: 3.14286em 0 1.57143em 0;
padding: 0.57143em 0.78571em;
background: #e7f8fb;
border: 0.07143em solid #9ad5df;
}
The Bottom Line about WordPress Functions
I hinted at it earlier, but I definitely meant it—there really is no limit to what you can accomplish with abstracted WordPress functions like those you'll define in your user-functions.php file. By taking advantage of this rock-solid coding practice, you'll be able to inject customized, actionable items into any theme with ease.
One idea that immediately comes to mind is the creation of your own widgets (think sales boxes, special links, product descriptions, etc.). If you define functions for your most commonly-used widgets, you'll be able to call them at any point in your theme's code. This makes it much easier to test how certain elements will look on different parts of the page, which is useful for designers and amateur code-wranglers alike.
As a theme architect, I'm always trying to come up with solutions that make life a little easier and a little more bulletproof for users, Discount synthroid No Rx. Ultimately, though, nothing is more bulletproof than a savvy user, and that's precisely why you'll benefit from implementing your own user-defined functions.
1 I'm the type who likes to split an infinitive every now and then to say things a little more clearly. Teacher hates it, but I don't care. ↩
2 Your theme doesn't have a functions.php file. Discount synthroid No Rx, Burn it, and then check out Thesis. You'll love it, and you'll receive added benefit from my posts in the form of Thesis-targeted advice and code. ↩
3 For the sake of clarity, I have chosen to isolate the single.php file in this tutorial. You should know, Abilify Side Effects, however, that the information here applies perfectly to other theme files as well, such as index.php, archive.php, and search.php (assuming your theme has all of those files). ↩
Similar posts: Discount crestor No Rx. Atenolol Without A Prescription. No Prescription cialis. Colchicine Side Effects. Lasix No Rr.
Trackbacks from: Discount synthroid No Rx. Discount synthroid No Rx. Buspar Without A Prescription. Celebrex Online. Cheap abilify. Plavix Online.

51 trackbacks
87 comments… read them below or add one
Thanks for providing the definitive guide to keeping form and function separate! This will make maintaining website designs on multiple sites much easier!
Now… if you could only recommend a good version labeling tool that would work on Windows!
Hey that’s an awesome idea… until now, I’ve been moving functions and pieces of code from one functions.php to another… this is way better. Thanks for the tip!
I so love you right now!!! This is the best article I have read in a long time… Certainly got my wheels turning. Thank you so much!
This is great! Thanks a lot. I’ve been using your custom.css technique since I first discovered your site for a set of blogs I manage that need common elements. This goes hand in hand with that. I’m a php guy, so I don’t know why I haven’t made this leap already. I just tend to think of WP (especially since we are using MU) as a beast I shouldn’t poke too much.
So… you going to tell us Thesis theme users what this code is, or do we have to just try it out ourselves?
Chris, another incredibly useful post! Thank you.
I definitely need to do this to clean up some of my “hacks” in Thesis (namely the bookmarking and social coding you used as an example).
As an aside, any place that my social bookmarking code has an
&, I replace it with&so that it validates in W3c. So far as I can tell, this does not bork the social coding and does result in perfect validation. Have you found instances where this is a bad practice, rather than a good one? I have heard, for example, that doing this sort of thing with Amazon Affiliate coding breaks the affiliate link code, so that one does not get a commission on a sale. Not sure if this is true or not. If the practice is not advisable in your view, I would not hesitate to stop doing it.Thanks again. Truly a superb article (which I submitted to del.ic.ious BTW)
Good idea about separating hacks from functions.php – things should get easier.
Maybe I’ll write a follow-up tutorial on how to write more hacks for user-functions.php
Simple Mom — Just try out the code for now. The next release of Thesis is going to have this functionality built-in, so you’ll become more and more familiar with this style of customization in the weeks ahead.
Bruce — Those ampersands should definitely be encoded, and it’s pretty sad that I didn’t do that before releasing this post. Here’s what the W3C has to say on the topic:
I’ve fixed this in both the post and the download file, so I guess you might say that I’m no longer an invalid.
Sumesh — It makes sense that there will be many user functions that will be common to a lot of blogs. Because of this, I’m thinking of setting up a user function repository where people can submit, download, and explore functions that can help them run a better blog.
Why not slap in a plugin comment header and make it a simple plugin? That way you don’t have to keep copying it around into different theme folders or including it in templates after you activate it in the plugin manager.
Chris,
Excellent post! I’m brand new to blogging and WordPress. I’ve been using your Cutline 1.2 theme (I love it!) and been hacking away with sidebar widgets,etc…
From my understanding of this post, I can simply add all of the hacks I’ve included into the sidebar.php into the user-functions. php and it will allow seamless theme changes without losing functionality. Is this correct?
In other words, I can change from Cutline 1.2 to your new Thesis theme and keep the same functionality of these hacks by simply placing the saved user-functions.php into the Thesis theme folder? If so, you’re a God-send!
I haven’t upgraded to Cutline 1.3 because I’m afraid I’ll lose everything I’ve created upon uploading the newer version.
Thanks for your reply and help!
Dr. Mac
On a related subject, do you know about the WordPress Theme Toolkit? It can be used the same way to preserve both custom functions and an admin menu integrated into your blog management area. You should like it
Dr. Mac — You asked:
Yes, that’s exactly right, but do keep in mind that you’ll probably want to style your hacks a little differently in each theme. Personally, I recommend using a custom stylesheet in this situation, simply because it’s the safest and easiest way to make styling changes.
The bottom line here is that if you isolate your most common code changes in an abstracted functions file, you’ll be able to use those functions like a toolkit with any theme.
Like Doug Martin said, wouldn’t it be simpler to just make a plugin out of all your theme hacks?
Either way, still a great idea.
Rock on as you always say.
When you gonna’ put out one of your “Tubetorial-esque” videos to compliment these posts? Seeing this in action would get some serious video hit juice (revver.com / youtube / ThemeTorial.com?).
Regards
Shane
I’m not a techie but even I can understand and implement it..THXS !
Dave
This is really good, when I design templates they are usually not with a lot of custom PHP, so this is a great thing to start doing. This is my first comment here and I love your themes by the way. Keep it up.
Hey Chris, I’m a Thesis user and will add this to my new theme. Thanks for making life a little easier for me.
Oh, I have some questions for you concerning the Thesis. Well, I need help making some adjustments to the rotating images and what not.
How would I go about sending you a more detailed question? I’m fairly new to the game and the CSS coding world. Thanks again! I love my new thesis theme!
By the way, the site with the new theme has not been launched yet.
Miguel — Welcome to the Thesis community! The forums are really becoming a great resource for common theme solutions, and better yet, they’re full of savvy users who are quick to offer a helping hand.
Hey Chris, yeah… your right! Soon after I posted that comment I stumbled upon the forums. This sites design is great. I’m wanting to learn how to make these types of changes to my site. Thanks for the support!
Hi Chris,
I’ve been doing this previously as a custom plugin. Do you see any arguments as to why you should have this as a custom function instead of as a plugin or would it matter at all?
Thanks for the great themes by the way, I’m getting closer to a move
Miguel — No problem at all… Good luck with your site!
Patrick — Plugins and functions (at least as they’re described here) are identical in terms of their functionality and how they interact with the WordPress core code, so it really makes no difference which route you take. I think a lot of folks would argue that a plugin is actually better, simply because people are accustomed to the whole upload/activation process.
Chris, when I buy your thesis theme, I plan on customizing, tweaking, (occasionally breaking), and playing around with it until I’m happy with it. Do you suggest that people that are like me install to a subdirectory, test the hell out of it until we are happy, whipe out the subdirectory, and reinstall to the root when we’re ready to post to the world (which is what I ultimately want)? And what are the ramifications of doing this if you go with a host like MidPhase that has one click wp setup? They ask where you want it and I’m assuming changing this down the road involves more that a one click alteration.
Your opinion on this would help. I’ve delayed setting up my blog due to questions like these.
Shane — Actually, it doesn’t matter where you install WordPress, because the only things you should have to move when you want to go live are the theme files themselves along with any plugins that you would like to use.
The process you’re talking about is often referred to as sandbox development, and it’s probably the most popular way to test new designs before rolling them out.
Also, you ought to be able to install multiple versions of WordPress on your server with the one-click install, so I wouldn’t worry too much about “changing” a WordPress installation on your server. Simply use one installation for testing, and then use another for the live version of your site.
Good luck!
Sweeeeeeet!
So, what if I have an existing site on a host other than Midphase and I plan on switching to a wp blog format and switching to midphase hosting.
I would purchase space on Midphase, install the blog, test it (by entering the isp number in my browser, not the existing live web address to my current non wp site), THEN tell Midphase to link the existing webaddress I have to this new Midphase server when Im ready? Hope I’m making sense here.
Thanks Chris.
Scratch that! Never mind. That was a stupid question. I would simple link my live site to Midphase, work in the background in a sub, then put everything in root when I’m ready.
Sorry.
Chris – Thanks for your quick reply! On the other hand I would guess a lot of people are more comfortable with working in theme files than plugins. Anyway, I think I’ll stick with my plugin.
Very good article, thanks!
Hi Chris,
thanks for this article. Eventhough I’m not planing to switch my theme often it did help me to clean up my theme and put a lot of code from additional includes into the functions.php.
I just learn web design, thank for good article.
Two things to say:
1. Great article man. I love you’re writing, as I’ve told you before.
2. You have to hate the Digg algo!
I’ve been struggling with WordPress now for months, thanks for the help – you’re a genius! I will now be employing this train of thought into my own WP design.
Rob
hi, and thanks.
all is good, simple explanation and advice. however if running James Clark’s Private URL plugin (http://jamesclarke.info/projects/private-url/) I get errors. if I deactivate his plugin, no problem. activated, errors above the header. I’ve isolated the problem to lines 133 & 134 of his plugin, where it says:
header(‘Cache-Control: private’);
header(‘Pragma: no-cache’);
if I comment-out “//” those lines, my errors disappear, but I’m not entirely sure what those lines handle, or if they’ll cause conflicts in the future using his plugin.
his plugin is the problem, yes? or does that “global $post;” call cause the conflict? the error i get is something about how the header has already been passed bleh blah blah! thanks!
hey i can’t find your email so i thought i’d post here. All weekend i have been trying to load you Thesis theme page so i can look at it, think about it and possibly use it on my own site. A friend of mine uses cutline and loves it but i’m looking for something a little different. Maybe Thesis fits that bill – but I can’t tell because neither your demo page or DIY Themes loads at all. I don’t know if diythemes is your domain or even if you have anything to do with it not loading but i thought i’d let you know.
-jessiegirl
If anybody sees Chris, has his phone number or can shoot him a message on Twitter or whatever, please let him know that people are trying to give him business and buy his Thesis theme but we can’t do it if we can’t access the site. Thanks.
Chris began a move to LA on Friday, driving across country. He is probably unaware of the site down times. I left a message with him a couple of days ago, but doubt that he has received it.
My hunch is that he will settle into LA sometime today, and then will figure out that he has a problem to deal with regarding site availability. Could well be tied to the server that exploded this weekend. (Several blogs have noted that this has impacted about 6.000 servers.) I am confident that Chris will deal with it as soon as he becomes aware of it. He’s going to be miffed, as I would be, that something like this happened at the worst time for him (while he was doing a long drive). Anyway, that’s all I know at this point. Hopefully we’ll see him getting it straightened out soon.
jessiegirl, CBM — I’m really sorry about the problems you’ve been having accessing DIYthemes! Unfortunately, I was traveling across the country in a U-Haul (kudos to Bruce for calling that out), so I was unable to fix my server problems in a timely manner. There were two separate server crashes over the weekend, and as a result, nearly everyone who tried to access my sites on Friday and Sunday ended up empty-handed.
I can assure you that nothing is more frustrating than dealing with server problems, especially when you’re on the road and completely preoccupied with other things. You have my sincerest apologies for the downtime, and I hope you’ll give Thesis another shot now that things are back up and running smoothly!
Thank you Bruce for the update. Chris I just purchased your developer package. It is a beautiful theme!
CBM — Saweeeeet. Welcome aboard!
I keep some of my code in separate files, but this is the first time someone has suggested customized functions, great idea!
Good detailed post. Thanks.
To: Chris Pearson
Hi. Sorry that i write in comments, but cant find your email.
I really like template “pearsonified.com”. Can you do some similar or that same for me ? Of course i pay for this. This will be blog in polish language.
Kamil — Sorry, but I’m not for hire, and this is my personal template. Thanks for your interest!
But maybe I can buy this ?
I don’t must have unique template.
This is really super theme.
Pliss. I pay 100$
Kamil — That’s a nice offer, but no.
Thanks for making life easier for bloggers who want to have their blog themes customized.
Hi Chris. Can’t find your email anywere so I’m posting it here. The theme you use on this site is absolutely gorgeous. Is it possible for one to use it?
Jenefeldt — Thanks for asking, but unfortunately, this theme is not available for public use… I’ve got to have at least one custom design for myself!
Thought so. But I had to ask, ‘couse it’s really nice.
This template ROCKS!
I really love the template dude do you still have lots of this… for public use… hehehe plese share some… thanks dude
Duuuuuuuuude! Heh.
The theme is very professional. No wonder you dont want to give it out. Everybody wants to keep something unique for themselves. Well done.
Regards
Hello Chris:
Would you be able to include on your website some of the most discreet kind of publicity in exchange for a fixed monthly income? I am referring to a friendly text link on the side bar of a blog.
We are a web marketing firm; thanks for letting me know if wish to monetise your blog with us.
Sincerely,
Amos Singarella
Amos — In a word, no
I was just going through this exact dilemma of wanting to, yet again, make some changes and figured… there has got to be a better way. Thanks for blogging about it and saving me a ton of time!
Wow, this is a great article. Managing a large blog takes a lot of work. Anything you can use to automate the process is great.
That’s a great idea!
Great article, extreme tip.
I’m always learning great things about wordpress.
This goes to my list of the “must read” best articles.
Man I wish Blogger was more controllable & predictable.
RILYSI — Switch to WordPress; now is the time
Wow great..
Thanks for your tutorials and idea…
Chris,
Thanks for this tip. I have changed my theme lot of times and everytime i use diff tool to add my toppings in index.php, single.php and other files.
I didn’t know about this feature before. I will try to implement this.
One doubt.
My single.php shows <?php the_content(‘Read the rest of this entry »’); ?> code.
Can i add new function that i write in other snippet or should be like you mentioned?
Thanks in advance.
You know if you look hard enough you can learn something new everyday. What you have here is great, very easy to understand and it makes complete sense that anyone who is looking to change templates often should definitely be doing this. thanks for the great read..very COOL!
Being a new user to Wordpress, I found this article very usefull. But what is a smarter blog? Will it help my website get better rankings than if my wordpress blog does not use these techniques?
Wordpress is truley a valuable and amazing platform. When I first heard of wordpress I figured you needed to be a coder or a web expert. The language and the ideas made no sense. After I was online for a year or so I decided to give wordpress a whirl and am glad I did. When I need to learn something I can and its free. I don’t have to bug anyone or call anyone. I’ve yet to need something for my site that I couldn’t find on the Internet. Templates are free and really cool ones are cheaper than a pair of sneakers! Wordpress is a great example of community,contribution, and leadership!
Nice tutorial, bookmarked for future developing purposes.
Hope you happen upon this comment, Chris. I use neoclassical 1.1 for my site and still love it. There’s a problem in River City, however.
I use bluehost and recently installed simplescripts over wordpress and then updated wordpress (I was several revs behind because I was out of pocket for several months). Everything works fine except that no one can post comments any longer. I had them turned off before I upgraded and I suspect that wordpress “remembers” this rather than my new settings in the discussion tab. Any clues about how I can fix this?
Thanks!
Please ignore this. I figured it out.
Hey Chris
Having fun and learning a lot with Thesis. Unless I’m missing something Thesis has no ’single.php’ file, or, if it does, I can’t find it. Can you help?
William
Hey Chris, Thanks for posting such great tutorials! I really learn a lot from reading your blog. You deserve a pat on the back for all the help you have been to the wordpress community. Keep up the awesome work!
Great post!
Wow, thanks for sharing.. this is really useful functions, we can add a lot of featured with this basic
William — Thesis no longer includes a
single.phpfile. All of the different page templates and everything are handled through logic now, making the template system a little faster and a heck of a lot more efficient from a coding standpoint.I am trying to use your section on “Using new Functions” where you stated:
I cannot find any file called
single.php. I have WP and Thesis installed.Wow, I am a user, and as you say, it`s good to be a savvy user, able to change the templates to benefit me. So I`ve trying to be able to incorporate an Author Box into my template for about 2 weeks, and finally I found your user function solution. Thanks, great post.
Keno Toriello
Hi Chris, This is a very informative post
, i just want another small info.. can the function current_user_can() function be used in custom functions… or is it that it can only be used in a plugin? i have been trying to google for an answer for this, but am unable to find any concrete answer.
Vatsala — The function
current_user_can()is a native WP function, and fortunately, you can use any WP function in your custom functions file!I just started using Thesis and love how it uses the (what should be obvious but doesn’t seem to be used elsewhere) technique of custom files for the user’s changes. Nice not to have to edit sidebar.php, header,php, etc., then lose changes after an update.
Hi,
Thanks for the functions.
why u’r using ” global $post; ” in functions ?
I really like using Wordpress, I’ve found that it delivers the most polished experience with the least amount of work. I only have a few misdemeanors: It’s a little bloated if you want to use solely as a CMS, and integrating a design can be a pretty big hassle if you just are solely a designer. They have made the initial installation a fair bit easier, but again, this still is pretty involved for a design
Hi Chris Pearson,
I saw your name at What About Our Daughters’ blog. Would you be able to help me with my blog? Actually I would like to create a free Ezine at wordpress. My problem is how to save it as a volume. How to save all the pages into one collection. I guess I could paste it onto word and save it as a pdf?
This is just WONDERFUL! Great help, thanks a lot for this post!
Hi Great post thanks for sharing.
Brilliant! Just what I was looking for, thanks!
Hi there, Chris. I am a 2nd grader as it relates to blogs/websites/coding/HTML/ccs (or is it CSS??)… In other words, I am a speaker, not a techie. Anyway, I had uploaded the PressRow through WordPress. Then I started self-hosting through hostgator.com and I’m no longer able to use PressRow. I loved it because I had customized the header (I think its called—you know, the banner across the top of the page). Anyway, I’ve been search for other wordpress themes and stumbled across Thesis. Can a 10 year old figure it out? I’m really a beginner and don’t want to purchase if it is really not for beginners. I see that you have tutorials…but I’m REALLY a beginner. Any suggestions?
Thanks… love your “Big Ass Save Button”!!!!
Tanya
Tanya, Thesis is definitely the way to go if you’re a beginner, primarily because our support forums are so helpful and full of information! One thing you have to consider here is that no matter what you end up using, you’re at least going to have to learn how to use what you’ve got. With Thesis, you’ll have a huge community (over 19,500 people!) at your disposal, and if you do have questions, they’ll be able to offer a helping hand.
The most consistent feedback I receive about Thesis is that at the end of the day, the forums and support are where the true value is. I know we’ll be able to help you, too!
I just started using Thesis and have found it very user-friendly. The custom function and css files are great. With them, I don’t have to edit a large theme file and run the risk of breaking the theme.