Luca Biagini | Marketing, Adv, Communication & Webdesign

Wordpress plugin: random subpages
Published on February 22, 2008

This is the very first plugin I’ve written for wordpress. It’s so simple and could be easily optimized, but it works and it’s still having success, with a large number of viewers where I have originally posted it on Gruppo Modulo (where is also available in italian version).

Wordpress Plugin Random SubPages lets you show a customizable number of random child pages (or just some elements of them) of a parent page.

It can be used to display random services of a parent service page, i.e.:

+ web solutions
- xhtml + css
- php scripting
- webcommerce tools
- seo and sem
- web adv
- dem marketing
- ecc

Or it can be used to show the members of a team:

+ XYZ Football Team
- player 1
- player 2
- player 3
- players 4
- etc

Download Random Subpages and unzip the folder on your pc.
Then upload random_subpages.php in wp-content/plugin and activate it from admin panel.

Then recall it, outside the loop, in the page you wish with this code:

<?php

/* edit first row to set the number of
pages to show and the parent page */

// as set right now,it will show 3 pages, child of page 4

$randompages = gruppo_modulo_rsp('numberposts=3&parentpage=4′);
foreach($randompages as $post) : // do not edit this line
setup_postdata($post); // do not edit this line

/* now it will be shown what you want to show from the selected pages
(for example title, content, meta, ecc), see example below.
you can add additional formatting using echo.
n the example we have placed the title between h3 tags */

echo "<h3>";
the_title();
echo "</h3>";
the_excerpt();
the_content();
the_meta();

// end of the customizable part; do not edit below

endforeach;

?>

Leave a Reply