WordPress.org

Support

Support » Plugins and Hacks » [Plugin: Custom Content Type Manager] featured image in array?

[Plugin: Custom Content Type Manager] featured image in array?

  • kryvulena
    Member

    @kryvulena

    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/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Contributor fireproofsocks
    Member

    @fireproofsocks

    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']);
    }
    kryvulena
    Member

    @kryvulena

    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!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Plugin: Custom Content Type Manager] featured image in array?’ is closed to new replies.