WordPress.org

Ready to get started?Download WordPress

Forums

Multiple Post Thumbnails
[resolved] can't get get_post_thumbnail_url() to work (4 posts)

  1. monkeykode
    Member
    Posted 1 year ago #

    I'm trying to set the secondary featured image as a background image, but when I use the function it only just returns:
    http://www.monkeykode.com/?%3E
    and not the proper url. Is this a bug, or am I implementing it wrong?

      <li style="background-image:url('<?php if (class_exists('MultiPostThumbnails')) : MultiPostThumbnails::get_post_thumbnail_url(get_post_type(), 'secondary-image'); endif; ?>
      ?>');"><?php the_post_thumbnail('post-thumbnail', array('alt' => get_the_title(), 'title' => get_the_title())); ?>
      <li class="overlay">

    Your help would greatly be appreciated!

    http://wordpress.org/extend/plugins/multiple-post-thumbnails/

  2. monkeykode
    Member
    Posted 1 year ago #

    <li style="background-image:url('<?php if (class_exists('MultiPostThumbnails')) : MultiPostThumbnails::get_post_thumbnail_url(get_post_type(), 'secondary-image'); endif; ?>
    ?>');"><?php the_post_thumbnail('post-thumbnail', array('alt' => get_the_title(), 'title' => get_the_title())); ?>
    <li class="overlay">
  3. wjgoodman
    Member
    Posted 6 months ago #

    I want to get just the URL of a secondary featured image as well. I tested this a few times and it just doesn't work. You are following the instructions perfectly.

  4. wjgoodman
    Member
    Posted 6 months ago #

    I just got it to work using another forum post's info

    <?php $custom = MultiPostThumbnails::get_post_thumbnail_id(get_post_type(), 'second-image', $post->ID); $custom=wp_get_attachment_image_src($custom,'second image'); echo $custom[0]; ?>

    It brings in the full image but now I can't seem to figure out how to bring in the smaller sizes. I will start another post to ask the question.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic