WordPress.org

Ready to get started?Download WordPress

Forums

Just need some clarification on get_post_meta() (5 posts)

  1. thetanooki
    Member
    Posted 4 years ago #

    Hi,

    A plugin I'm using assigns a custom value to each post. In my case, it creates the key wppt_4x3 and the value is given in the form of an URL to the thumbnail created.

    I've read through the WordPress documentation on get_post_meta() for custom values, but I'm confused as to how I would call that custom value (URL) from within the image tag as the image's source location. Everything I try doesn't seem to take, and the resulting source code shows the image source as blank.

    Any clarification on this? Thanks in advance!

  2. esmi
    Forum Moderator
    Posted 4 years ago #

    Try <img src="<?php get_post_meta($post->ID, 'wppt_4x3', true); ?>"

  3. thetanooki
    Member
    Posted 4 years ago #

    Thanks for the response. This is pretty much what I had, but I tried again with what you provided exactly. Same result, for some reason I just keep getting the alt text instead. Here's what the source code says is outputting:

    <img src="" alt="thumbnail image" width="100" height="75" />

  4. esmi
    Forum Moderator
    Posted 4 years ago #

    Are you sure that the custom field wppt_4x3 stores the image url?

  5. thetanooki
    Member
    Posted 4 years ago #

    Unless there's something hidden that I don't know about, then yeah - I'm looking at it right on the Edit Post screen.

    If it helps, here's the plugin in question: http://www.seoadsensethemes.com/wordpress-wp-post-thumbnail-plugin/

    Towards the bottom of the actual info post, the author provides a code for theme developers to insert the thumb manually into themes. This code doesn't work, and speculation is that something with the plugin isn't compatible with 2.8.4. However, the plugin itself still works, as it will still automatically insert the thumb at the beginning of the_content (or the_excerpt, if you know where to make the edit). I tried it with the_excerpt, but part of the reason I'd rather insert it manually is because I don't want the thumbs with all my excerpts (multiple loops).

    I asked if anyone knew a workaround for inclusion in themes, as seen at the bottom here: http://www.seoadsensethemes.com/0-2-beta-2-release/ I was given an example code, but it doesn't work - it doesn't call the image. But I noticed they used get_post_meta, which sure enough the URL for the thumbs is stored as a custom value when I checked. I'm just trying to get a working code out of it.

    Again, unless something else is hidden, there shouldn't be much more to it. The key name is wppt_4x3, and the URL provided is indeed the thumb location. Am I missing something?

Topic Closed

This topic has been closed to new replies.

About this Topic