0

I inherited a site with a custom php file for a custom sidebar. The sidebar is pulled in to action on pages using the "About" template. The sidebar is supposed to be displaying the image of the person whose profile it is on the top of the sidebar. Only one of the 4 profiles is pulling the correct image (the other 3 are trying to pull images from an old dev site that no longer exists). So, I need to update the 3 pages to pull images from the current site. But, I can't for the life of me figure out where to do that because I can't figure out where the photo is being pulled from. The profile pages are just regular pages whose parent is the "meet the team" page and they are using the About Page template.

The code in question is this:

<img src="<?php $image = get_post_meta(get_the_ID(),'image',true); $profile = get_post_meta(get_the_ID(),'profile',true); print $image; ?>" />

Any help or insight into what photo this is pulling would be greatly appreciated.

  • of note, these fields will all break if you ever change the root URL of the site – Tom J Nowell Mar 27 '17 at 18:33
0

$image = get_post_meta(get_the_ID(),'image',true);

This line is pulling the URL of the image from a custom field for that particular profile page. Do you see any custom fields in the admin there? Make sure you have the custom fields checkbox checked in the screen options tab (top right in the page admin).

0

First, is the issue that you aren't getting the right ID of the custom post type? Or, are you just not getting the right meta data of that post?

As you can see from the function of get_the_ID, it uses the ID from the global $post variable if used outside the loop. So if you are on a page (eg page id 123) that calls the sidebar which has this bit of code, it seems that it is trying to pull the post meta data for the page you are on (page id = 123). Not knowing your database or how the post_meta was saved, I can't tell you what's in there or how it got there.

What you will need to do is use the ID of the profile you want to display. I assume by 'profile' you mean a custom post type.

Once you are using the right ID, I would say you'd have to search through your theme code or any plugins to see how the post meta data image is saved.

Sorry I can't be more specific. If you can elaborate on your problem and/or give a live link, it would be more helpful.

0

Thanks, everyone, for your help! The problem was the I forgot to check in Screen Options to make sure the Meta Fields were showing. I was desperately looking for them but didn't see them, so I thought maybe it was pulling a photo in a way other than what I assumed it was doing. Sometimes it's the most obvious solution...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.