- This topic is empty.
-
AuthorPosts
-
February 19, 2010 at 2:31 am #28072NipperkinMember
Hello all,
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:
Code: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?
February 19, 2010 at 12:21 pm #71201john010117MemberWhat were the error messages?
February 19, 2010 at 1:29 pm #71209NipperkinMemberHere they are:
Quote: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 53Warning: 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.
February 19, 2010 at 4:44 pm #70749john010117MemberTry:
Code:<?php
$f_contents = file (“./slogans.txt”);
$line = $f_contents[array_rand ($f_contents)];
print $line;
?>or
Code:<?php
$f_contents = file (get_bloginfo(‘stylesheet_directory’) . “/slogans.txt”);
$line = $f_contents[array_rand ($f_contents)];
print $line;
?>February 19, 2010 at 5:52 pm #71214NipperkinMemberThe second one worked! :P Check it out if you like: http://inanindeterminateplace.com.
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.
-
AuthorPosts
- The forum ‘Back End’ is closed to new topics and replies.