WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Display an image based on div? (4 posts)

  1. dfwgreg
    Member
    Posted 2 years ago #

    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
    else
    display code.

    The img code I'm using:

    <?php
    		$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.

  2. SpankMarvin
    Member
    Posted 2 years ago #

    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.

  3. dfwgreg
    Member
    Posted 2 years ago #

    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:

    <div=toppost>
    One post
    </div>

    If two stickies are enabled, it goes to this:
    <div=topcolumn>
    1st post 2nd Post
    </div>

    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:
    http://pastebin.com/48BdfKYG

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

  4. dfwgreg
    Member
    Posted 2 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.