I'm new to the forum and a relative new-comer to WordPress and PHP. I've created a couple of sites in the past and am currently blogging. My question concerns the implementation of the "Random Slogan Displayer" http://css-tricks.com/snippets/php/random-slogan-displayer/ on my WordPress blog. My goal is to replace the blog description in the header with a quote that changes each time someone visits the blog, changes pages, etc.
I've tried to set it up twice and failed each time. As instructed, I created a .txt file of a list of quotes and uploaded it to the wp-content folder in my theme folder on my server. I don't know how to "give permission" to the file (and frankly I'm not even sure what that means), so that may in fact be the problem. At any rate, I included this code snippet:
on a page and gave it a whirl: as I said, it didn't work. The first time, nothing happened, the second time I got a couple of error messages that appeared where the quote should have. My question is: what am I doing wrong? I'm assuming that it should work more or less as I described/as the instructions suggest, but then again I may well be wrong.
My blog can be seen at http://inanindeterminateplace.com, should anyone wish to take a peek. Any help would be appreciated.
Thanks in advance.
Oh and, by the way, what is the purpose of the "textmate snippet" function on the snippet pages?
Warning: file(quotations.txt) [function.file]: failed to open stream: No such file or directory in /home/content/s/e/e/seeingeyebooks/html/indeterminateplace/wp-content/themes/satorii/search.php on line 53
Warning: array_rand() [function.array-rand]: First argument has to be an array in /home/content/s/e/e/seeingeyebooks/html/indeterminateplace/wp-content/themes/satorii/search.php on line 54
Let me add that I changed the name of the file from "slogans.txt" to "quotations.txt" and replaced the former with the latter in the code as well.
I'm new to the forum and a relative new-comer to WordPress and PHP. I've created a couple of sites in the past and am currently blogging. My question concerns the implementation of the "Random Slogan Displayer" http://css-tricks.com/snippets/php/random-slogan-displayer/ on my WordPress blog. My goal is to replace the blog description in the header with a quote that changes each time someone visits the blog, changes pages, etc.
I've tried to set it up twice and failed each time. As instructed, I created a .txt file of a list of quotes and uploaded it to the wp-content folder in my theme folder on my server. I don't know how to "give permission" to the file (and frankly I'm not even sure what that means), so that may in fact be the problem. At any rate, I included this code snippet:
on a page and gave it a whirl: as I said, it didn't work. The first time, nothing happened, the second time I got a couple of error messages that appeared where the quote should have. My question is: what am I doing wrong? I'm assuming that it should work more or less as I described/as the instructions suggest, but then again I may well be wrong.
My blog can be seen at http://inanindeterminateplace.com, should anyone wish to take a peek. Any help would be appreciated.
Thanks in advance.
Oh and, by the way, what is the purpose of the "textmate snippet" function on the snippet pages?
Let me add that I changed the name of the file from "slogans.txt" to "quotations.txt" and replaced the former with the latter in the code as well.
[code=php]<?php
$f_contents = file ("./slogans.txt");
$line = $f_contents[array_rand ($f_contents)];
print $line;
?>[/code]
or
[code=php]<?php
$f_contents = file (get_bloginfo('stylesheet_directory') . "/slogans.txt");
$line = $f_contents[array_rand ($f_contents)];
print $line;
?>[/code]
If I were the kind of person that said "WOOHOO!!!", I'd say "WOOHOO!!!"
That's really great – thank you so much for your help.