• Skip to primary navigation
  • Skip to content
  • Skip to primary sidebar

WP SITES

2470

Original Genesis Tutorials & 5000+ Guaranteed Code

Snippets

  • Subscribe
  • Register
  • Videos
  • Log in

Need Help? - Get Coding Support Now

Random Fallback Featured Images For Custom Archive Page

This code enables you to display a random featured image on any archive page type, if non is added. On top of this, it doesn’t display any duplicates so all images will be unique.

There’s at least 2 ways to do this, both of which are included in this premium tutorial for members.

Firstly, lets check the demo video.

Demo Video

In this demo, we’ve added 6 unique images to a folder named random in the child themes root directory. We’re added the code directly to the archive-portfolio.php template file which displays 6 posts per page. The code makes sure a unique image is displayed for each entry on each archive page if no featured image is added, otherwise it displays the featured image.

Tested using the Minimum Pro child theme by StudioPress in the archive-portfolio.php template file.

Note : If you want to use a unique random image for each paginated archive page, you will need to add the same number of images to match your posts per page settings. Example : If you are showing 20 posts per page, you’ll need to add 20 unique images named 1.png to 20.png in the random images folder.

Here’s the code for logged in members

Click here to get full access to all tutorials

Related Tutorials

  • Random Images Using PHP Code

Featured Image Minimum Pro

Primary Sidebar

Recently Coded

  • Magazine Pro – Move Entry Date Back To The Default Position In The Post Info
  • Showcase Pro – Remove Featured Image & Show Same Page Header
  • Infinity Pro – Change Team Page From 4 To 3 Columns
  • Infinity Pro Vertical Menu
  • Genesis Sample Theme – Custom Archive Page Template With Different Hero Images

Brad Dalton Specializes In Genesis child theme customization & code modification.

Advertise · WPEngine · Genesis · Log in

  • Membership
  • by Theme
  • Contact
  • RSS
  • Newsletter ( Twice Weekly )