Add Random Post with Shortcodes Ultimate

Wordpress Plugins

Generating a Random Post in WordPress

There are many plugins out there that an generate a random post to be inserted into your website. An example of such a random post is shown to the right of this entry in the box-set off. Some of the plugins come with their own shortcodes. But there’s no need to install another plugin if you have Shortcodes Ultimate installed.

Shortcodes Ultimate by Vladimir Anokhin is a popular plugin for WordPress supplying numerous helpful shortcodes to add various features to your posts.

Using Shortcodes Ultimate to Generate a Random Post

This method permits you to customize the random listing so that it can include only the title, the title and the featured image, or even the entire content.

  1. Install the Shortcodes Ultimate plugin if you haven’t already.
  2. Customize Your Shortcodes Ultimate Template

  3. On your server, in the “wp-content/plugins/shortcodes-ultimate/” folder, create a new file called “random-post.php”. You can do this through the file manager on CPanel or other frontend on your host (or through SSH if you have command line access).
  4. Grab This Code for Your Shortcodes Ultimate Template

  5. Edit the “random-post.php” to add code for your random post – use (and modify if you wish) from one of the following:
     

    Template Code to Show Random WordPress Post Showing Just the Title and Featured Image:

    Template Code for Random Post To Show Full Content

    Random Template Code To Show The First Few Paragraphs of WordPress Post

    NOTE: This option is not recommended as it will arbitrarily truncate your post content including HTML tags which may mess up the formatting on the rest of the page where this code is inserted) .

  6. After pasting in one of the three above, save the file.

Try Out The Random Post Short Code

  1. Click on the Shortcodes Ultimate button in your editor:

    Shortcodes Ultimate Insert Shortcode Button

  2. A dialog will open. Click on the “Posts” code:

    Shortcodes Ultimate Posts Button

  3. Edit the Template name to read “templates/random-post.php” to match the name of the template you just created.
  4. Screenshot Template Name

  5. Complete the rest of the dialog options. When finished, click “Insert” to insert the Posts short code.
  6. Preview the post to verify that a random post was inserted.

Leave a Reply

Your email address will not be published. Required fields are marked *

*******************************************************