get feature image from custom field

Posted in: Newsmag
Post count: 46

i want to get the feature image from custom field which is set in backend

can anybody help me out with this ?
what code do i need to insert to get the desired output and what files needs to be updated ?

Post count: 6535

Hi

The theme get the featured image from post meta filed from the data base. To change that you need modify in td_module_single_base.php the function get_image() function: http://screencast.com/t/MAcitvOMC0B Note that is a complex task which require good coding skills and if you don’t know how to do it my advice is to look for a developer from sites like http://studio.envato.com/ to do it for you as we’re not available for any customization services at the moment.

Thanks for the message!

Post count: 46

Hi Andrei L.

i am using Newmag theme

and in td_module_single_base.php i dont have get_image() function can you give me any other solution

Post count: 6535

Hi

The get_image function should be in td_module_single_base.php as you can see here: http://screencast.com/t/pPHh1Cdt so please check this again.

Thanks!

Post count: 46

Hi what code do i need to edit can you tell me here

Post count: 6535

Hi

You need to call your custom field here: http://screencast.com/t/5WhD5hrN then use it to display the featured image from it: http://screencast.com/t/3NJXMb0dFvt As I said above this is a complex task and I cannot offer a quick solution now. I recommend you to find someone to help you with it if you don’t know how to do it yourself as we are not available for any custom services.
Hope this help.

Thanks for the message.

Post count: 46

I am the developer here
and i have tried the get_post_meta() in the functions.php, index.php , single.php , post.php

however i didn’t got desired result .
as i want my post’s feature image should come from the custom field which is mentioned in the post

you just tell me which part of the code to edit and what exactly i need to put there

if you could help me i am very thankful to you

  • This reply was modified 10 years by Pravin.
Post count: 6535

Hi

Please provide a link or more details about the theme version that your using. Also provide more details about what type of value is stored in your custom field, for example, a link, an image id etc, and we will try to find a solution at your request.

Thanks!

Post count: 46

I am using theme Newsmag V 2.2
and in my custom field i have image path or URL you can say for ex. ‘entry-preview’ , ‘grid_thumb’ is the custom field and its values is ‘http://mydomian.com/wp-content/my-gallery/2015/09/my-custom-image.jpg’

Post count: 1291

Hi,

Try the following code – http://screencast.com/t/OonNlk8gK

$custom_field_img = get_post_meta( $this->post->ID), 'custom_field_key', true );
if ( ! empty( $custom_field_img ) ) {
$featured_image_info['src'] = $custom_field_img;
}

Replace custom_field_key with the name of your custom field.
If it doesn’t work please send an email and provide wp-admin and ftp access so we can take a look.

Thank you!

  • This reply was modified 10 years by Emil G.
  • This reply was modified 10 years by Emil G.
Post count: 46

no this doesn’t worked for me 🙁 🙁

see i will tell you everything in detail
i have my old wordpress site and now i have to upgrade it to new wordpress with this Newsmag theme
now in my old site i have different custom field for each every post which has different image path which is called in the frontend as feature image through code “get_post_meta( get_the_ID(), ‘thumb’, true );”

so since i have upgraded my wordpress with new theme now this theme is taking the default thumbnail which is blank (a default image thumbnail) throughout the site ..

so how can i get those custom fields image url set as feature image throughout the site ????
what files do i need to edit and what code do i need to insert ?

Post count: 9544

One thing you might try, if you already have an image “in the post” of some type is do what I did; use the “auto post thumbnail pro” plugin which will automatically take first image from post (or from external site, if necessary) and then generate thumb and assign as “featured” image in every post.

This saves having to hack WP, the theme, the image files, etc.

Make back up of your dbase, first, obviously, but might be worth a try if that is what you’re trying to do — get existing images into the default WP “featured” post field.

Post count: 1291

Hi,


@Pravin
– My solution will only replace the output on the post page.
To make it display on all modules you have to set the custom field image as a featured image. This is not an easy task and i cannot provide a quick solution, you could look on the web, ex – http://stackoverflow.com/questions/4371929/convert-custom-field-image-to-become-featured-image-in-wordpress – or hire a professional developer to do this for you.

Thank you!

Viewing 13 posts - 1 through 13 (of 13 total)
You must be logged in to reply to this topic.