WordPress.org

Ready to get started?Download WordPress

Forums

Get the Image
Echo => False seems not to work (WP 3.4) (4 posts)

  1. lospasionados
    Member
    Posted 1 year ago #

    First of all: Great plugin Justin!

    However I have a problem with implementing it. Have a function where I call a custom post time, and I want get_the_image() to return the image in stead of printing it directly.

    This is my code:

    $output = '<ul>';
    $args = array( 'post_type' => 'plots', 'posts_per_page' => 10 );
      $loop = new WP_Query( $args );
      while ( $loop->have_posts() ) : $loop->the_post();
      $output .= '<li>';
      $output .=  get_the_image(array('echo' => 'false'));
      $output .= '<a href="';
      $output .=	get_permalink();
      $output .= '">';
      $output .=	get_the_title();
      $output .= '</a><br />'.get_the_excerpt().'</li>';
      endwhile;
    $output .= '</ul>';
    
    return $output;

    The thumbs are being shown, but unfortunately all together at the beginning of the page, and not as part of the unordered list where I want to have it. Am I doing something wrong or is it the plugin part of 'echo' => 'false'?

  2. Bill Dennen
    Member
    Posted 1 year ago #

    Just wanted to say that I am seeing similar behavior.

  3. Bill Dennen
    Member
    Posted 1 year ago #

    You might want to try:

    get_the_image(array('echo' => false ));

    that is, no quotes around false.

  4. Bill Dennen
    Member
    Posted 1 year ago #

    In a previous version, I used code similar to this:

    get_the_image('echo=0');

    or

    get_the_image('echo=false');

    Now with the update, this echos the images incorrectly.

    I think this is because echo is actually set to a string -- "0" or "false", depending on syntax. The way $echo is checked in the code now, it must be set to a boolean (false).

    The correct syntax would seem to be:

    get_the_image(array('echo' => false ));

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.