• Resolved lberelson

    (@lberelson)


    I’m not totally well versed in reading api’s so i’m having trouble understanding how to use the wp_get_attachment_image_src (or other appropriate tag) to a list of posts of category ‘3’ and their affiliated photos (as uploaded and using either.
    I need the correct tag and syntax for using the file url of a media element for posts of category ‘3’
    site: http://howlingwolfmedia.com/site3/classes/instructors/
    A sample thumbnail is hardcoded in template to demo desired display.

    I’ve tried the following but i’m not using it correctly

    <?php query_posts('category = 3');
    while (have_posts()) : the_post();
    ?>
     <?php wp_get_attachment_image( $attachment_id, $size, $icon, $attr ); ?>
    <h4 class="bio" style="font-weight:bold;"><?php the_title() ?></h4>
    
    <? img src="wp_get_attachment_image" ?><?php the_content(); ?>

    as well as wp_get_attachment without the img src preface on last line

    Do I need to create an actual function to employ this? There already is a function to handle img src attachments in wp-includes/media.php so I’m confused.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter lberelson

    (@lberelson)

    Sorry, couldn’t edit the post…I had revised code as follows…

    <?php query_posts('category = 3');
    while (have_posts()) : the_post();
    ?>
    <h4 class="bio" style="font-weight:bold;"><?php the_title() ?></h4>
    <?php wp_get_attachment_image_src(); ?>
    <?php the_content(); ?>
    <p> </p>
    <p> </p>
    <hr>
    <?php
    endwhile;
    ?>

    Also tried (category = ‘3’) as well as (category = 3)
    Media is working and affiliated with posts per upload
    http://howlingwolfmedia.com/site3/files/2013/07/beckham.jpg

    Thread Starter lberelson

    (@lberelson)

    FORGET USING GET_ATTACH etc… I’ll use the featured image option.
    Added this to function file ‘add_theme_support( ‘post-thumbnails’ ); ‘
    Added this to template: <?php echo get_the_post_thumbnail($page->ID, ‘thumbnail’); ?>
    And now I can use that solution. Just have to figure out the code to float left the image.

    Thread Starter lberelson

    (@lberelson)

    Also solved the category problem. Proper syntax for the version of WP i’m using 3.4.2 is (‘cat=3’) category no longer seems to be spelled out. Yea!! Issues resolved.
    I also altered the main attribute of the post image to float in my stylesheet… since i didn’t know how to add a special class to the code below.
    img.wp-post-image {
    float: left;
    margin: 12px 6px 0 0;
    }

    FINAL CODE works and now need to add permalink

    <?php query_posts('posts_per_page=6', 'cat=3');
    while (have_posts()) : the_post();
    ?>
    
    <h4 class="bio" style="font-weight:bold;"><?php the_title() ?></h4>
    
    <?php echo get_the_post_thumbnail($page->ID,  array(65,65) ); ?> 
    
    <?php the_content(); ?>
    <p> </p>
    
    <hr>
    <?php
    endwhile;
    ?>

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

The topic ‘get attachment image syntax basics’ is closed to new replies.