WordPress.org

Ready to get started?Download WordPress

Forums

Custom Content Type Manager
featured image in array? (3 posts)

  1. kryvulena
    Member
    Posted 1 year ago #

    Is it possible a posts' listing including featured image added to custom post 'actor' and content of a custom field 'item' created/added at 'actor' in this code?

    <?php
    $my_array = get_custom_field('actor:to_array','to_link');
    foreach ($my_array as $item) {
    print $item . '<br />';
    }
    ?>

    I'd like to get something like this:

    <a href="LINK_TO_ACTOR">FEATURED IMAGE HERE<br />ACTOR's NAME HERE<br />ITEM HERE</a>

    Thanks for your help in advance.

    http://wordpress.org/extend/plugins/custom-content-type-manager/

  2. fireproofsocks
    Member
    Plugin Author

    Posted 1 year ago #

    Yes, it's possible, but you'll need to change your code. I'm assuming your "actor" field is a relation field that has "is repeatable" checked, yes? In that case, the more flexible option is to use a different output filter. Try using the get_post output filter: http://code.google.com/p/wordpress-custom-content-type-manager/wiki/get_post_OutputFilter

    <?php
    $actors = get_custom_field('actor:get_post');
    foreach ($actor as $a) {
        print '<a href="'. $a['permalink'] .'"><img src="'.$a['thumbnail_src'].'" />'. $a['post_title']  . '</a><br />';
    }
    ?>

    The "thumbnail_src" is a convenience placeholder, but it's only available if you're using the built-in WP "Featured Image", NOT a custom image field. If you're using a custom image field, it all boils down to "How do I convert a post ID to the image that's represented by that ID": http://code.google.com/p/wordpress-custom-content-type-manager/wiki/FAQ

    E.g.

    $actors = get_custom_field('actor:get_post');
    foreach ($actor as $a) {
       print wp_get_attachment_image($a['my_image_field']);
    }
  3. kryvulena
    Member
    Posted 1 year ago #

    Hello

    Thanks so much for your quick reply - this will definitely help. Yes, I use the default "featured image" WP option, so it should be OK :-)

    THANK YOU!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.