Author: Prabhu Balakrishnan
-
WordPress – How to save default values in theme options page?
If you are a wordpress plugin or theme developer, when creating a theme options page, have you ever wondered why you get Notice: undefined index warnings, thrown by the wordpress debugger. This because when you activate the theme, there is absolutely no values initialized (not even empty values). I am assuming that you are storing…
-
WordPress – How to remove the dots in excerpt endings?
By default wordpress, automatically adds the […] to while clipping the excerpt extra data. This you will notice in the homepage when the blog posts show up. Personally, i dont like this and i always fix this by replacing [..] to something like either remove it or with couple of dots. Here is the snippet…
-
How to replace strings or tags inside content in WordPress?
With wordpress is pretty easy to filter and replace tags that occur inside the content. Lets say you have the content with <php> tags and want to replace it as <pre> tag. All you need to do is write a filter in your theme file <strong>function.php</strong> ,that finds and replaces all occurrences of php tags, which is so…
-
How to include php files in wordpress?
Any good theme or plugin developer would break the theme files into small ones and then included them as and when needed. This way you you save yourself from the cumbersome job of editing each and every php file. But, how you do you include the php file, the correct way in wordpress. If you…
-
How to add jquery to WordPress theme?
WordPress uses jquery by default and you dont have you do anything extra, most jquery scripts and plugins should pretty much work well by default. so, how to add jquery the correct way? Its easy and can be done with just 3 lines of code and can be done in a couple of ways.Go to…
-
How to list posts for every category in WordPress
If you are building a news site or a directory based theme, you might like to print all categories and then output 10 recent posts in every category, through the use of the loop. Here is the snippet of the wordpress code, that does that. Basically its a double loop, first loops through all categories,…
-
Setting default values to options fields array in WordPress
Lets say you are working on a plugin/theme having numerous option fields in admin setings, but you want to initialize them with default values. Not setting them with default values, can lead the wordpress debugger to throw, undefined index which is nasty. Careful that you are not storing the values in database, but only in…
-
How to dynamically change stylesheet colors in WordPress
Lets say you are implementing a color picker in wordpress options page, but you want to dynamically change colors or background for your header, menu or a link. Here is how to do it correctly and its unbelievably simple in wordpress. Just add a hook to wp_head and look at the code snippet below. function…
-
Tutorial: How to add color picker to wordpress options page?
It is very easy to add colour picker with just 10 lines of code on the fly. I am gonna teach you how to use Iris colour picker to the input box in your wordpress options page. I am going to keep this very simple and short and i will not go deep on creating wordpress…
-
Fixing CSS drop down menu clipped by div element
I was working on how to clode a pure css dropdown menu and stumbled upon a very strange problem. The problem was the drop sub UL elements would get clipped by the div container. I initially thought that the problem was overflow:hidden or not setting the z-index. But i was wrong, setting overflow to visible…