Does the title ring a bell? I bet it does. It must remind you of the article i wrote quite some time ago titled “Get rid of the sociable plugins. Do it yourself!“. It helped a lot of people save some CPU time and memory usage. Now it’s time for the newsflash! The idea came to me after i read this article on a modification for the theme. It actually gives a very nice little admin area on the theme options but it fiddles with the database so i decided to show you how you can do the same thing without any query run.
Firstly, i will summarize all the steps we are going to take in order to achieve this:
The result will look something like the following.
Time to get our hands dirty. First of all create a new file called “newsflash.txt” on the home folder of your currently used theme. Then, open the file index.php (or home.php in some themes) and find the place where the loop begins. That usually is just before a line looking like this:
Right before that line inject the following snippet of code:
Let’s take the code line by line here so you can understand what’s going on.
Now let’s move onto the CSS part. Open the style.css file (or any file that is your theme’s stylesheet) and add the following lines at the bottom:
This will render a dashed yellow box with the newsflash. A few notes here:
I would like to say that it’s much more preferred to load the newsflash from file rather make a query to the database. Ofcourse it also depends on your needs. If you need complicated management of newsflashes then this is probably not a method for you. On the other hand, if you have basic newsflash needs this is the way i’d recommend. And, as always, if you have trouble implementing, let me know and i’ll do my best to troubleshoot and help you out!