Hi! We do use a custom field named _nelioefi_url. Now, do you see the first underscore? That means that the custom field is “private”, and therefore it should not be shown in the Custom Fields metabox. I’m no expert on the API you mention, but is it possible that private custom fields are not returned?
Hi David thanks for the reply and explanation. I didn’t know that custom fields starting with an underscore are special. I think your right, these private custom fields are the reason the API doesn’t return them. I couldn’t find a good explanation on how to update these hidden custom fields through the XML-RPC API. The most promising post seems to be this one because he’s talking about “Using custom_fields with meta_id”. Does the explanation make sense to you?
The only option I can think of right now is to modify your plugin and remove the underscores. That should be fairly straight forward and solve my problem, don’t you think?
Thanks again 🙂
Yes. The easiest solution is to remove the underscore. In fact, you don’t need to edit our plugin at all. Just add the following piece of code in your theme’s functions.php file:
add_filter( 'nelioefi_post_meta_key', 'nelio_remove_underscore' );
function nelio_remove_underscore( $meta_name ) {
return 'nelioefi_url';
}
And that’s it! From now on, the meta_name our plugin uses will be nelioefi_url. What’s great about this solution is that there’s no need to modify the plugin after you update it with a new release (that’s why we added the filter in the first place).
That said, using “regular” (instead of “internal”) metas might cause some trouble, for you can edit them directly using WordPress built-in meta editors… but I’m sure you’ll be careful!
Best,
Thanks for your reply David!
I removed the underscores and it’s working out great. I had to change a few things in the plugin anyway to make it work in my theme, such as using a 2×3 pixel gif to change the aspect ratio of the thumbnails.
$html = sprintf(
//'<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" ' .
// use a 2x3 image to define the poster aspect ratio
'<img src="data:image/gif;base64,R0lGODlhAgADAIAAAP///wAAACH5BAEAAAAALAAAAAACAAMAAAIChF8AOw==" ' .
'style="background:url(\'%s\') no-repeat center center;' .
'-webkit-background-size:cover;' .
'-moz-background-size:cover;' .
'-o-background-size:cover;' .
'background-size:cover;' .
'%s%s" class="%s wp-post-image nelioefi" '.
'alt="%s" />',
//$image_url, $width, $height, $additional_classes, $alt );
// ignore the image width and height, the theme css will take care of that
$image_url, 0, 0, $additional_classes, $alt );
These modifications can’t be done in the theme’s functions.php file I suppose, right? Anyway wouldn’t that just move the problem? If the plugin is updated, my modification would still be in the theme’s functions.php file. But if the theme is updated, then my modifications are still lost, right?
Reason for asking is that I’m modifying a lot of php files lately and I am sure I’m going to run into problems with updating! Just trying to figure out where would be the best place for my modifications.
Thanks again, really cool plugin.