Viewing 3 replies - 1 through 3 (of 3 total)
  • You could always just use the built-in WP get_post_meta() function. You might have to do some data manipulation if you want the image src, but it’s definitely doable, since CCTM just saves field values as postmeta.

    Thread Starter mike.lucas

    (@mikelucas)

    The problem I’m running into is that I need to try and turn the post id into the image id for the custom field.

    I’ve tried these, but I don’t get the image id or the URL to the image:

    $post_thumbnail_id = get_custom_field($post_ID, 'wine_bottle_image');
    $attachmenturl = get_custom_field($post_ID, 'wine_bottle_image');
    $attachmenturl = get_custom_field($post_ID, 'wine_bottle_image:to_image_src');

    If I hard code an image ID, I get the correct image

    $post_thumbnail_id = 437;
    $attachmenturl = wp_get_attachment_url($post_thumbnail_id);

    Any suggestions?

    Plugin Contributor fireproofsocks

    (@fireproofsocks)

    Have you verified that the other plugin is storing the value as expected in the wp_postmeta table? The get_post_meta() function would be a more transparent window into that table.

    Your syntax for get_custom_field() is incorrect: that function is meant to be called within the context of an existing post (i.e. the post-id is implied). See https://code.google.com/p/wordpress-custom-content-type-manager/wiki/get_custom_field

    It expects a field name, NOT a post id. You will not have a custom field named 1 or 2 or whatever the post id is.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Accessing custom field from another plugin’ is closed to new replies.