• I need to have a custom field auto populated.

    I have to use the Featured Post option in wordpress but the theme requires i select a “Post image”.

    Can i make is so the Post Image value pull the image URL of the Featured Image?

    I have been messing around with Custom Field Template for hours and can not get it to work.

    I have added “Add Post Thumbnail Shortcode” plugin so in my head all i need to do is have the custom field post_image = [post_thumbnail]

    I need to be able to do all this without actually opening the “post new” page as posts will be made from a mobile device. No custom fields are available on app based wordpress.

    Thanks in advance.

Viewing 9 replies - 1 through 9 (of 9 total)
  • Moderator keesiemeijer

    (@keesiemeijer)

    try it with this in your theme’s function.php. It will insert the shortcode above the post content.

    function add_thumbnail_shortcode($the_content){
    return '[post_thumbnail size="thumbnail"]'.$the_content;
    }
    add_filter('the_content', 'add_thumbnail_shortcode');

    Thread Starter treble6

    (@treble6)

    Thanks for your help.

    That put the featured thumbnail above that post. What i need is for the featured image to be associated with the themes “post_image”. In the hope that where ever the theme uses “post_image” the featured image will be used.

    Moderator keesiemeijer

    (@keesiemeijer)

    So the “post_image” is a custom field?
    What theme are you using?

    Thread Starter treble6

    (@treble6)

    Yes, the theme is called rising. Im using auto post thumbs to create the featured images. I guess an answer would be to hack the auto post thumbs plugin to post to the database for both fields??

    Moderator keesiemeijer

    (@keesiemeijer)

    As this is a premium theme which you paid for, your purchase should have included support from either the theme author or where you purchased the theme from. It would be best to contact them for specific instructions on how to customize the theme.

    Isn’t it easier to alter the theme to always use “Post Thumbnails:
    http://codex.wordpress.org/Post_Thumbnails

    Thread Starter treble6

    (@treble6)

    Done that, they want more money to change it…

    I assume it wouldnt be to difficult to do but i know little about the way wordpress is written so trying to think of a quick fix for now

    Moderator keesiemeijer

    (@keesiemeijer)

    We cannot really help because we would have to look into the theme’s template files to make the alterations.

    Try it with this in your functions.php:

    add_action("save_post", "my_save_post");
    function my_save_post($post_id ){
        if($parent_id = wp_is_post_revision($post_id)){
        $post_id = $parent_id;
        }
        if(has_post_thumbnail($post_id)) {
          $large_image_url = wp_get_attachment_image_src( get_post_thumbnail_id($id=$post_id), 'large');
    
          update_post_meta($post_id, 'post_image', $large_image_url[0]);
        }
    }

    This will set the custom field “post_image” to the “large” Post Thumbnail (if there is one) when saving or updating a post.

    Thread Starter treble6

    (@treble6)

    Thanks again but that didnt work either.
    This is the code is the blogroll i need to modify

    [Code moderated as per the Forum Rules. Please use the pastebin]

    As you can see, the ‘post_image’ is called

    Moderator keesiemeijer

    (@keesiemeijer)

    “Thanks again but that didnt work either.”

    Did you try updating a “Post” with a Post Thumbnail?

    “der_postmeta” and “post_thumb” are not native WorpPress functions. As I said before, as this is a premium theme we cannot really help.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Is it possible to auto populate a Custom Field.’ is closed to new replies.