I’m trying to get a random quote on my site. I have taken the code below from my legacy site but cannot get it to display anything within WordPress, regardless of the theme I am using. The code is as follows:
<?php /* Pull quote from file for header */ $quote = file("localhost/assets/wp-content/themes/atahualpa34/inchrist.txt"); srand((double)microtime()*1000000); $inquote = $quote[rand(1,count($quote))]; /* End pull quote */ ?>
I suspect the problem is in the “$quote = file(“….); line. The text file with the quotes is in the theme’s root directory. I have tried file(“/inchrist.txt), file(“inchrist.txt), as well as the full path above. I have tried it with and without the plugin Exec-PHP.
The quote should display with the single line of code:
<?php echo $inquote; ?>
Can anyone point me in the right direction, please?
- The topic ‘Random quote in header’ is closed to new replies.