• I have a spreadsheet (Google sheet) featuring words. I then pick words at random from each column to make a complete sentence.

    What is the smartest way to replicate this on a WordPress page?

    I’d like a ‘generate’ button to press and reveal a new randomly-generated sentence using the words in the database each time.

    I there a plugin I could use?

    I’d like to avoid an iframe if possible.

    I’d also like the option to include a ‘tweet this’ button which would share any sentence the database has randomly generates after pressing the button.

    Hope this makes sense.

    Thanks in advance.

    Richard

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator bcworkz

    (@bcworkz)

    I’m not aware of such a plugin, but that doesn’t mean one does not exist. Your main task is getting the data into a structured array from which your code can easily pick sentence elements at random. Code to pick the elements and assemble them into a string is relatively simple.

    How the data becomes a structured array depends on how you want to maintain the data. You could have your code read the Google docs source. This greatly complicates the code required, but it’s possible AFAIK. On the other extreme, assemble the data into a PHP array declaration and maintain the data by editing the PHP code. In between is to have code read an intermediate, exported file format such as CSV that is easier to code the reading of.

    Sharing on Twitter requires using the Twitter API. There are plugins for sharing on Twitter, you could likely adapt one if it doesn’t work out of the box, or at least study how it interfaces with the Twitter API as a guide for developing your own code.

    Thread Starter thebuzzfactory

    (@thebuzzfactory)

    Hi bcworkz,

    Really appreciate this.

    I’ve found this code. https://codepen.io/chiragbhansali/pen/EWppvy (It seems to do the things you describe?)

    And this plugin. https://en-gb.ww.wp.xz.cn/plugins/custom-css-js/

    So, to my mind, I can use this plugin to enter the adapted CSS and JS code before popping the HTML in the page. (I’m pushing a little beyond my comfort zone here!!)

    I know things a rarely as simple as I assume. But worth a try?

    Cheers,

    Richard

    Thread Starter thebuzzfactory

    (@thebuzzfactory)

    … tried it. It isn’t that simple! 🙁

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Random sentence generator project’ is closed to new replies.