Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End Random Slogan Displayer

  • This topic is empty.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #28072
    Nipperkin
    Member

    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?

    #71201
    john010117
    Member

    What were the error messages?

    #71209
    Nipperkin
    Member

    Here 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 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.

    #70749
    john010117
    Member

    Try:

    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;
    ?>
    #71214
    Nipperkin
    Member

    The 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.

Viewing 5 posts - 1 through 5 (of 5 total)
  • The forum ‘Back End’ is closed to new topics and replies.