Support » Fixing WordPress » Display an image based on div?

  • Resolved dfwgreg


    Hey everyone,
    Is there a way to display html code based on the div name? I’m using the attachment img code is different sizes are displayed.

    For example:
    If <div id=”topcolumn”>
    display code
    display code.

    The img code I’m using:

    		$attachments = get_children( array('post_parent' => get_the_ID(), 'post_type' => 'attachment', 'post_mime_type' =>'image') );
    		foreach ( $attachments as $attachment_id => $attachment ) {
    		echo wp_get_attachment_image( $attachment_id, 'Front Group' );
    		} ?>

    Thanks for the help and thanks to everyone that have answered my questions.

    It is greatly appreciated,
    Gregory S.

Viewing 3 replies - 1 through 3 (of 3 total)
  • SpankMarvin


    IMO, you are approaching this in the wrong order. Since you are looking at changing the way an image is displayed based on the id of the div tag, you’re surely better off defining this in a template, between those tags?

    I.e. since the tag placements are consistent, there’s not really any need for conditionals within them, it would seem.



    I know this would be a difficult question to ask but what about a way to add something that triggers the image to display?

    I have a loop set up like. This is what happens when a normal post is shown:

    One post

    If two stickies are enabled, it goes to this:
    1st post 2nd Post

    Both will show an image attached to the post. Are there other options to change the image. Like from ‘medium’ in one post to thumbnail in the two stickies?

    This is the full text of index.php:

    Thanks. Hope this clears up some confusion,
    Gregory S.



    I think I’m going to have another custom field with separate code. I wanted to do an if statement but I don’t think I can accomplish it. Oh well.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Display an image based on div?’ is closed to new replies.