0

I use a script to generate the ranking page http://joereddington.com/ranking.html from a script. Here's a relevant bit of the script:

cat $DIR/start.html > $DESTINATION_PAGE
grep -o "<img.*Global rank.*" * | sed -e 's/<[^>]*>//g' | sed 's/\(^.*\):\(.*\)/<\/td><td><a href=\"http:\/\/\1\">\1<\/a><\/td><td> \2 <\/td><td><\/td><\/tr>/' > thelist.txt
cat thelist.txt | sort -n -k 3 | head -n 60 > thelist2.txt
cat thelist2.txt | nl | sed 's/^/<tr><td>/g' >> $DESTINATION_PAGE
echo "</table><br> Ranking last updated at: " >> $DESTINATION_PAGE
date >> $DESTINATION_PAGE
cat $DIR/end.html >> $DESTINATION_PAGE

You can view the full script at this github project. What I'm doing to generate this page is that I'm taking a static html version of the normal pages on my blog (split into two parts) and just squashing the html in with the generated table to create something that 'looks' reasonable. This clearly isn't the best way of putting regularly changing text into a wordpress installation. So what is the best way of putting regularly changing text into a WordPress install?

1

I don't know how one would define "best", but a possible approach would be to make your rankings page an actual page within WordPress, then add either a shortcode or a filter on the_content to populate/fetch a transient from the database. You could alternately save it in an option or as post meta and cron a script to update the option/meta periodically. WP CLI may be of interest to you as well.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.