WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] User Submitted Posts Plugin

[Resolved] 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) 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 15 replies - 1 through 15 (of 40 total)
  • I think it may just be getting the border,

    border: 2px solid #464646

    if you can do without it try removing it.

    if you need it, you may try adding it in your style.css with the appropriate body class, that way it doesn’t get called untill there’s an image.

    thanks for your help deepbevel.

    I removed border: 2px solid #464646

    but the dead link is still there. Just without a border. 🙁

    you probably need to mod your code with a condition added to “if is public submisission-echo addimages”, it may need to be followed by an “else return” or something. I’m not sure how to write it though, I’d have to mess with it.

    It looks different in firefox, not sure but I think it looks how it should.

    yeah man!!
    damn. There’s no deadlink in firefox!

    haha, Any solutions to make the site load like it does on firefox?

    that I have no experience with, and no clue. You’d probably have to know what it is that ie is not doing right.. might be easier to mod the condition so nothing renders if no image.

    if_is_public_submission (and if an image exitsts!) bla bla bla

    this might provide a clue, they are talking about if-no-image conditionals.

    http://wordpress.org/support/topic/displaying-standard-imagecustom-field-image-if-no-image-excists?replies=7

    I’d try something like this, but of course it’s not tested and I’d be shocked if it worked as is.

    <?php global $wpdb;
     $query = "SELECT ID, guid FROM $wpdb->posts WHERE post_type = 'attachment' AND post_parent = '{$post->ID}'";
    
    if ($attachments) {
    
     $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;} ?>" />
    <?php }
    ?>

    Unfortunately, the images don’t appear at all.
    hmmm

    do my eyes deceive me..? is it fixed? no way my code worked, no way.

    hmmmm, maybe need to get the post id in the condtional?

    if ($attachments) {
    
    if (post_parent = '{$post->ID}'){
    
    bla bla bla
    
    <?php } }?>

    but again, I realy doubt i’m writing it correctly. It would be great if coder would jump in here right about now.

    ha no. I don’t think its working.
    It just stopped displaying all images.

    even the posts that have images aren’t displaying.

    I’m just happy it didn’t brake your page, at least my syntax must be right. maybe try it with the id. Could be it’s needed to get the images that do exist.

    haha now the whole site’s not loading.
    only the header’s left.
    This is the current code i have on

    <?php global $wpdb;
         $query = "SELECT 'ID', 'guid' FROM '$wpdb->posts' WHERE 'post_type' = 'attachment' AND post_parent = '{$post->ID}'";
    
    if ($attachments) {
    if (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;} ?>" />
    <?php }
    ?>
Viewing 15 replies - 1 through 15 (of 40 total)
  • The topic ‘[Resolved] User Submitted Posts Plugin’ is closed to new replies.
Skip to toolbar