How to add a random post button in WordPress

by teachyourselfwebsites.com

I used this method to add a “random post” to this site. I didn’t create a child theme. So it will break when the theme gets updated.

http://teachyourselfwebsites.com/create-random-post-button-wordpress-blog/

4/24/2016 note:

Here are some details. You need to create a new file inside the theme called page-random.php based on the original page.php.

the added code looks like this and goes right before get_header():

 

<?php
/* Template Name: Random Post */

$randomPost = get_posts(array(
 'numberposts' => 1,
 'orderby' => 'rand'
));
 
foreach ($randomPost as $post) {
 wp_redirect(get_permalink($post->ID));
 exit();
}

Soundcloud short-codes

This code comes from clicking the Share button on the SoundCloud clip, then using the “WordPress Code”

If you find old-style SoundCloud post on a 3rd party site, you may need to get the ’embed’ code and then add it to your post, using the html editor

 

 

test of WordPress text-expander plugin

Following this line, is some text to expand…

It uses shortcodes for the formatting…

[ expand title ]
text
[ /expand ]

 

this
is
some
text

Here is a Max patch in compressed text format. Enclose it in <pre> </pre> tags

----------begin_max5_patcher----------
528.3ocyU0ziaBCD8L7qvBodZCD7GXC6sH0iUUUppm5tph.N65JvNBbTy1U6
+8ZafDRhVET2UzdH1iey3g27xLvy9dAqU64sAfaAeG348rummCxB30e1KnNe
eQUdqKr.I+Wp0+LXQmKMeu1AuoQU29T8ZU0fqs45hGExG9QCuP28DHwQwK.P
paKEaWQlUv88WYiRpk40bWFW0HxOjLqmVwucdfDyE6fk6pExJt1QM3QP0N84
nhRWVMbOLaHqcgoeZKuieAAf6sddw22tr3sIIMlzyABoFroRkquptfhcaYvY
QWvWpKrWWWVz+68TeDZdy0aVPtMb7+plE57zrrswznb8VjtQGb5rnFwWpFjf
+hRtl21l+.+hZd0pu7IvcAIDTDhbWf4+5kzknXHB.iuESyqMNgLHDhvHi6u8
0OZ.97xUfPfY0fDNb6DygSLMyR86DJi0ev5GBO2D16EhRhRoVravQDBiYvFr
BA2DGQIevEXHlFkAy5roYQrzNSHEEkhs2GRIQIz96bfyGRwwr1URiKAXZDEO
xzDzH2iKdyS7TdMx4fTWIj7B0NoSuIWq6paMAxralB68p6BM0YMzDm0b7xUb
m8oKWoYwOsarUsqoXHU8eA.br5J4sZgLWKTxQwvNIlGEkkb43ohZQ4VkYnsm
BuxKClJinSfQYyJiXSfQjYmQv+qXDZBZD8MvHygW7+yzP0RM
-----------end_max5_patcher-----------