Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

sbryan

macrumors member
Original poster
Jun 6, 2007
96
0
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', false, false);
	}
}
?>
 

jakeOSX

macrumors regular
Mar 24, 2005
123
31
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.
 

jrock2004

macrumors 6502
May 4, 2008
375
0
PA
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', false, false); 
    } 
}
echo "</div>";
?>

Then in your stylesheet do
Code:
#imageHolder
{
      margin-right: 20px;
}

That should work but I am not 100%
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.