• Resolved breakuppedia

    (@breakuppedia)


    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 - 16 through 30 (of 40 total)
  • If all else fails, consider using default code in your template content area that aligns the images how you want. Seems a [gallery] could do it.

    But, the template you use for that would render all post images as galleries automatically, so you would only use that template for user submitted posts.

    Thread Starter breakuppedia

    (@breakuppedia)

    Is it possible to use the default code.

    And then add an additional code that will null the default code if there are no attachments?

    Sorry if this is a dumb statement. Im really new at this 🙂

    that’s what I’ve been playing with, but with no luck. i just don’t know how to tell wp to show an image, only if one exists. I’ve done it before but the context was different. I’m not great with this either. I help out partly to learn.

    <?php echo do_shortcode('[gallery]'); ?>

    you could try that in your content area, instead of the code you are using

    Thread Starter breakuppedia

    (@breakuppedia)

    Damn!
    It’s working!
    I think.
    but its kinda turned all the images into thumbnails.

    Should I just add:

    <img style="float: left; height: 380px;border: 2px solid #464646;" />

    hey wait, in the last code you posted you don’t have

    <?php } }?>

    instead you have

    <?php } ?>

    fix it and try again.

    or keep working with the gallery code. the choice is yours

    Thread Starter breakuppedia

    (@breakuppedia)

    Thanks for helping anyways deepbevel!

    If you stay with the gallery method you can change the thumbnail size in image settings.

    Thread Starter breakuppedia

    (@breakuppedia)

    You mean like this?

    <?php echo do_shortcode('[gallery]'); }}?>

    The site went blank again, with only the header left

    no, I was talkiing about the original code,

    <?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 }
    ?>

    if you still want to go that route.

    Thread Starter breakuppedia

    (@breakuppedia)

    Damn!
    u’re good!!

    change
    <?php }?>
    to
    <?php }}?>

    Thread Starter breakuppedia

    (@breakuppedia)

    This is currently working for me

    <?php echo do_shortcode('[gallery size= large]'); ?>

    but just for us to learn. I’ll try the old one with your fixes.

    I’m lucky, sometimes.

    Thread Starter breakuppedia

    (@breakuppedia)

    nope. the old one didn’t work with the }}!

Viewing 15 replies - 16 through 30 (of 40 total)

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