Random Quotes Plugin For WordPress

in this tutorial we will make a free random quotes plugin for wordpress hope you will love it. the visitor can get another quote every time a button is clicked or reloading this web page .

How To Make a Plugins For WordPress

In this Tutorial i will teach you how to make plugins for wordpress in few simple steps.

Building a plugin for wordpress is very simple and easy  all what you need to do is to create a Php file with a function add some code then upload it to your wordpress as a plugin and use it .

First lets make a  php file and  name it randoom quotes.php 

Next Make Quotes.txt file with your quotes one by line and upload it in the root of your web site .


Adding Header Requirements and your php scritp

Next open your randoom quotes.php using wordpad or notepad

GO TO https://developer.wordpress.org/plugins/plugin-basics/header-requirements/

and coppy the Header Requirements code or just use this :

 * Plugin Name: YOUR PLUGIN NAME

after adding ths code you only need to add a fonction in your randoom quotes.php file

function randoomq()

$file= “Quotes.txt“;
$bglist = file($file);
$randombg = rand(0, count($bglist)-1);
echo “$bglist[$randombg]” ;


this fonction will pick a quote from the file Quotes.txt and will print it in your page but for this we need to add a shortcode then we can insert a this functionality without any HTML codes .

to do this we need to add this ligne :

add_shortcode('randoomq', 'randoomq');

now we can use [randoomq]  to show our quotes in any page we want .

next we have to add a button

echo “<button onClick=\”window.location.reload();\”>Next Quotes</button>”;

This will allow us to reload the page and show a new quotes randoomly.

Next To do is to save your code in zip format then we can upload it as a local plugin.

local plugin.

Or just Download it from this link : Download Random Quotes Plugin For WordPress

Now we are ready to test our plugin.

Go to your  wordpress dashboard then plugins then Add New

plugins then Add New



Then upload plugin

upload plug

now you can upload your zip file

upload zip

Select your zip File randoom quotes.zip and click install

plugin installed successfully

Now you plugin is installed successfully you have to click Activate Plugin .

Put your shortcode :[randoomq] where do you want to show your quotes save changes and enjoy your Random Quotes script .