I have made my 1st php code and I think its amazing lol probably not, it goes to a random post but in a much better way if you go to a 404 on my website yont.co.uk and type some jiberish after a "/" you can see. (it doesn't show a random post as such, it redirect to a random post)
My problem is, does any one think it will mess my SEO up?
In functions.php I replaced:
if (theme_get_option('theme_show_random_posts_on_404_page')) {<br /> theme_ob_start();<br /> echo '<h4 class="box-title">' . theme_get_option('theme_show_random_posts_title_on_404_page') . '</h4>';<br /> ?></p> <ul> <?php<br /> global $post;<br /> $rand_posts = get_posts('numberposts=5&orderby=rand');<br /> foreach ($rand_posts as $post) :<br /> ?></p> <li><a>"><?php the_title(); ?></a></li> <p> <?php endforeach; ?> </ul> <p> <?php<br /> theme_post_wrapper(array('content' => theme_ob_get_clean()));<br /> }
with:
if (theme_get_option('theme_show_random_posts_on_404_page')) {<br /> $posts = get_posts('post_type=post&orderby=rand&numberposts=1');<br /> foreach($posts as $post) {<br /> $link = get_permalink($post);<br /> }<br /> wp_redirect($link,307);<br /> exit;<br /> }
The reason I ask is because I have never heard of anyone making a code like this and its probably for SEO reasons.
Ps: is my 1st code good? I have no idea what I am doing but some how works lol.
[No bumping, thank you.]