Random Redirect for Attachments of a post.
-
I want to use matt’s random redirect plugin …
but not for posts, i want to use it for picture attachments of that post?Following is the if condition Matt is using, how can it be modified for attachment of a single post( which say have post id = 1)
`if ( isset( $_GET[‘random_post_type’] ) ) {
$post_type = preg_replace( ‘|[^a-z]|i’, ”, $_GET[‘random_post_type’] );
$query = “SELECT ID FROM $wpdb->posts WHERE post_type = ‘$post_type’ AND post_password = ” AND post_status = ‘publish’ ORDER BY RAND() LIMIT 1″;
}$random_id = $wpdb->get_var( $query );
wp_redirect( get_permalink( $random_id ) );
exit;`
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Random Redirect for Attachments of a post.’ is closed to new replies.