CSS Help: Styling PHP Results

Discussion in 'Web Design and Development' started by sbryan, Aug 23, 2009.

  1. sbryan macrumors member

    Joined:
    Jun 6, 2007
    #1
    I was hoping a fellow Wordpress user could help me out with this PHP function which returns thumbnails for images attached to the post. The function seems to be absolutely impervious to styling and I would very much appreciate any suggestions this thread produces.

    What I'm trying to do is display the results inline with a margin-right of 20px. The images themselves are 85x65px.

    Here's the PHP code for you Wordpress users:

    PHP:
    <?php 
    $args 
    = array(
        
    'order'          => 'ASC',
        
    'post_type'      => 'attachment',
        
    'post_parent'    => $post->ID,
        
    'post_mime_type' => 'image',
        
    'post_status'    => null,
        
    'numberposts'    => -1,
    );
    $attachments get_posts($args);
    if (
    $attachments) {
        foreach (
    $attachments as $attachment) {
             echo 
    wp_get_attachment_link($attachment->ID'thumbnail'falsefalse);
        }
    }
    ?>
     
  2. Eraserhead macrumors G4

    Eraserhead

    Joined:
    Nov 3, 2005
    Location:
    UK
  3. jakeOSX macrumors regular

    Joined:
    Mar 24, 2005
    #3
    it seems the HTML output is bured in another PHP function.

    Here is what I would do. Look at the html of the rendered page (browser-> view source) and see if the images have labels or ID's. if so, CSS'ing them should be easy (-er...)

    if not, you'll have to dig into the php a bit more and find where the HTML is created. there, you need to add ID's.
     
  4. jrock2004 macrumors 6502

    Joined:
    May 4, 2008
    Location:
    PA
    #4
    What if you if you did this:

    PHP:
    <?php
    echo "<div id='imageHolder'";
    $args = array( 
        
    'order'          => 'ASC'
        
    'post_type'      => 'attachment'
        
    'post_parent'    => $post->ID
        
    'post_mime_type' => 'image'
        
    'post_status'    => null
        
    'numberposts'    => -1
    ); 
    $attachments get_posts($args); 
    if (
    $attachments) { 
        foreach (
    $attachments as $attachment) { 
             echo 
    wp_get_attachment_link($attachment->ID'thumbnail'falsefalse); 
        } 
    }
    echo 
    "</div>";
    ?>

    Then in your stylesheet do
    Code:
    #imageHolder
    {
          margin-right: 20px;
    }
    
    That should work but I am not 100%
     

Share This Page