In this post i will show you a easy way to add different header images for each page or post in your blog / website. The fastest way to achieve this is to use Custom Fields, this allows us to add additional meta information to posts. In the next example the header image it is set as background.
Let’s start with the admin panel.
First we need to upload the image from “Library” and copy the path to the image.
Now back to our post we set up the custom field for the header image. I called the variable “headingImage”, you can use whatever name you like, but keep in mind that it has to be the same name for all posts / pages, and set the value with the path of the image that we uploaded earlier.
Now lets take a look at the code that we have to write in the header.php file, from our theme.
/** * Custom page headers using custom fields */ $customHeader = get_post_custom_values('headingImage', $post->ID); if (isset($customHeader[0])) { $page = $customHeader[0]; } else { $page = null; }
Now we have the image with the full path, remember that our image is set as background so we have to change it using JavaScript, or overwriting the CSS style, in our case #headerimg. The default value for the header image is set up in the CSS file of the theme.
Note: Dont forget to verify if there’s a custom field set up, or you can end up having no header displayed.
Here is the JavaScript approach, i used jQuery since i needed in some other parts of the project.
jQuery(document).ready(function(){ var imagine = ''; if (imagine != ''){ jQuery('#headerimg').css('background','url('+imagine+')'); } });
Here is the CSS style overwriting method.
#headerimg { background:url() no-repeat 0 0; }
That all that you have to do to have different images on each post or page of your blog or website. This is a basic usage of the “Custom Fields” feature from WordPress, but it can be used in finding solutions in much more complex situations.
Finally, there’s another very important peculiarity of what does Cialis that brings it so high above its alternatives. It is the only med that is available in two versions – one intended for use on as-needed basis and one intended for daily use. As you might know, Viagra and Levitra only come in the latter of these two forms and should be consumed shortly before expected sexual activity to ensure best effect. Daily Cialis, in its turn, contains low doses of Tadalafil, which allows to build its concentration up in your system gradually over time and maintain it on acceptable levels, which, consequently, makes it possible for you to enjoy sex at any moment without having to time it.