Title: User Submitted Posts Plugin
Last modified: August 20, 2016

---

# User Submitted Posts Plugin

 *  Resolved [breakuppedia](https://wordpress.org/support/users/breakuppedia/)
 * (@breakuppedia)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/user-submitted-posts-plugin/)
 * Hello Im using the User Submitted Posts plugin to all users to post to the front
   page.
 * I use the code below in my content.php to get the pictures to appear too. Its
   all find when the users submit a photo.
 * Problem is when the users don’t add a photo, there is a dead link that appears.(
   you can see this happening here: [http://www.breakuppedia.com](http://www.breakuppedia.com))
   Do help me if you can.
 * Thank you so much!
 * <?php global $wpdb;
    $query = “SELECT `ID`, `guid` FROM `$wpdb->posts` WHERE `
   post_type` = ‘attachment’ AND `post_parent` = ‘{$post->ID}'”; $adimages = $wpdb-
   >get_results($wpdb->prepare($query), OBJECT); // To display the first image..?
   >
 * <img style=”float: left; height: 380px;border: 2px solid #464646;” src=”<?php
   if(is_public_submission()){echo $adimages[0]->guid;} ?>” />

Viewing 10 replies - 31 through 40 (of 40 total)

[←](https://wordpress.org/support/topic/user-submitted-posts-plugin/page/2/?output_format=md)
[1](https://wordpress.org/support/topic/user-submitted-posts-plugin/?output_format=md)
[2](https://wordpress.org/support/topic/user-submitted-posts-plugin/page/2/?output_format=md)
3

 *  [deepbevel](https://wordpress.org/support/users/deepbevel/)
 * (@deepbevel)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/user-submitted-posts-plugin/page/3/#post-3144560)
 * oh well, like I said I’d be shocked if I could improv that kind of code. Glad
   you have a fix.
 *  [deepbevel](https://wordpress.org/support/users/deepbevel/)
 * (@deepbevel)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/user-submitted-posts-plugin/page/3/#post-3144562)
 * keep in mind, if users can add more than one image it will appear also, not sure
   how that will work for your layout.
 *  Thread Starter [breakuppedia](https://wordpress.org/support/users/breakuppedia/)
 * (@breakuppedia)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/user-submitted-posts-plugin/page/3/#post-3144564)
 * I will restrict it to a single image!
 *  [deepbevel](https://wordpress.org/support/users/deepbevel/)
 * (@deepbevel)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/user-submitted-posts-plugin/page/3/#post-3144565)
 * you can limit the number of images with this function:
 *     ```
       function get_random_gallery_images(){
       	global $wpdb,$post;
       		$ids = "";
       		$counter = 0;
       		$number_of_posts = 1;
       		$args = array(
       		'post_type' => 'attachment',
       		'numberposts' => 1,
       		'post_status' => null,
       		'orderby' => 'rand',
       		'post_parent' => $post->ID
       		);
       		$attachments = get_posts($args);
       		if ($attachments) {
       			foreach ($attachments as $attachment) {
   
       				if ($counter != 0) {
       					$ids .= ','.$attachment->ID;
       				}
       				else {
       					$ids .= $attachment->ID;
       				}
       				$counter++;
       			}
       		}
       		return $ids;
       }
       ```
   
 * output code:
 *     ```
       <?php
       $attachment_ids = get_random_gallery_images();
       echo do_shortcode('[gallery columns="3" include="'.$attachment_ids.'" link="file"]');
       ?>
       ```
   
 *  [deepbevel](https://wordpress.org/support/users/deepbevel/)
 * (@deepbevel)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/user-submitted-posts-plugin/page/3/#post-3144566)
 * but if you have another method, go with it.
 *  Thread Starter [breakuppedia](https://wordpress.org/support/users/breakuppedia/)
 * (@breakuppedia)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/user-submitted-posts-plugin/page/3/#post-3144569)
 * oh the plugin comes with a “for dummies” form for us to restrict number of images.
 *  Thread Starter [breakuppedia](https://wordpress.org/support/users/breakuppedia/)
 * (@breakuppedia)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/user-submitted-posts-plugin/page/3/#post-3144572)
 * If you’re interested, I’m working on another problem here:
 * [http://wordpress.org/support/topic/runo-lite-move-title-of-post?replies=1](http://wordpress.org/support/topic/runo-lite-move-title-of-post?replies=1)
 *  [deepbevel](https://wordpress.org/support/users/deepbevel/)
 * (@deepbevel)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/user-submitted-posts-plugin/page/3/#post-3144575)
 * well, guess we’re resolved. carry on.
 *  Thread Starter [breakuppedia](https://wordpress.org/support/users/breakuppedia/)
 * (@breakuppedia)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/user-submitted-posts-plugin/page/3/#post-3144577)
 * Thanks Deephevel!
 * Best Help ever!!
 *  [deepbevel](https://wordpress.org/support/users/deepbevel/)
 * (@deepbevel)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/user-submitted-posts-plugin/page/3/#post-3144579)
 * ah shucks

Viewing 10 replies - 31 through 40 (of 40 total)

[←](https://wordpress.org/support/topic/user-submitted-posts-plugin/page/2/?output_format=md)
[1](https://wordpress.org/support/topic/user-submitted-posts-plugin/?output_format=md)
[2](https://wordpress.org/support/topic/user-submitted-posts-plugin/page/2/?output_format=md)
3

The topic ‘User Submitted Posts Plugin’ is closed to new replies.

## Tags

 * [Coding](https://wordpress.org/support/topic-tag/coding/)
 * [Pictures](https://wordpress.org/support/topic-tag/pictures/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 40 replies
 * 2 participants
 * Last reply from: [deepbevel](https://wordpress.org/support/users/deepbevel/)
 * Last activity: [13 years, 6 months ago](https://wordpress.org/support/topic/user-submitted-posts-plugin/page/3/#post-3144579)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
