Home › Forums › Calendar Products › Events Calendar PRO › How can I find the name of a custom field?
- This topic has 8 replies, 3 voices, and was last updated 10 years, 9 months ago by
Support Droid.
-
AuthorPosts
-
October 29, 2013 at 3:10 pm #73671
Oliver
ParticipantHi,
I added some custom fields and want to print them via php in an RSS feed – like this:
echo tribe_get_custom_field(‘_ecp_custom_1’, $post_id);Unfortunately I only get back an empty string!
I guess that the name of the custom field used is wrong. I had a look in the source code of the site and tried the id (“tribe_custom_rechteinhaber-name-des-fotografen-bei-foto-upload-anzugeben”) and name (“_ecp_custom_1”), but both didn’t worked.How can I find the correct name of the custom field?
Best regards,
OliverOctober 30, 2013 at 4:21 pm #73887Oliver
ParticipantHi guys!
I also tried this, but only got back an empty array:
print_r(tribe_get_custom_fields( get_the_ID() ));Can someone give me a hint what’s wrong?
Best regards,
OliverOctober 30, 2013 at 5:09 pm #73903Barry
MemberHi Oliver,
So long as you’re already within the loop it should work pretty much as you seem to be using it. My only comment would be that if your field is named “Human Readable” then that is what you should pass as the parameter, rather than “human-readable”, example:
echo tribe_get_custom_field('Human Readable');In your case you are passing in the post ID – are you certain it is correct? The only other consideration is that tribe_get_custom_field() is geared toward retrieving additional fields in the Events Calendar PRO sense. If you are actually trying to use regular WordPress custom fields then you should use the relevant WordPress API functions.
Does that help at all?
October 31, 2013 at 10:09 am #74057Oliver
ParticipantHi Barry,
The $post_id works definitly (I set it and print it out a line before) 😉
I had a look in the Events->Admin page (thanks for that hint, a very useful page!) and found the following:
custom-fields =
Array
(
[0] => Array
(
[name] => _ecp_custom_1
[label] => Rechteinhaber
[type] => text
[values] =>
)[1] => Array
(
[name] => _ecp_custom_2
[label] => E-Mail Adresse für Rückfragen (Adresse wird nicht veröffentlicht)
[type] => text
[values] =>
)
}From my point of view the filed “name” should be the parameter I should pass to the function. Am I wrong? Nevertheless I tried the “Human Readable” as the parameter, but it didn’t worked.
Best regards and thanks for your support!
OliverNovember 4, 2013 at 8:26 am #74504Oliver
ParticipantHi Barry,
do you have any news for me regarding this issue? Can you check with your development team to get an answer soon, please?
Best regards,
OliverNovember 4, 2013 at 12:14 pm #74571Barry
MemberSo again can you try using the ‘human readable’ form (the label)? In your case:
$field_label = 'E-Mail Adresse für Rückfragen (Adresse wird nicht veröffentlicht)';
$result = tribe_get_custom_field($field_label);November 5, 2013 at 4:49 pm #74892Oliver
ParticipantNow it works! If found the problem 🙂
The documentation is wrong! It says that the functions returns a string, but it returns an array (that’s a big difference! “echo” prints out nothing if a array is given):
http://docs.tri.be/Events-Calendar-PRO/function-tribe_get_custom_field.html
Please correct the documentation!The working code is as follows:
$field_label = ‘E-Mail Adresse für Rückfragen (Adresse wird nicht veröffentlicht)’;
$cpy = tribe_get_custom_fields($post_id, $field_label);
echo $cpy[$field_label];Best regards and good night!
OlIverNovember 6, 2013 at 2:06 pm #75011Barry
MemberHi Oliver,
Sounds like you arrived at a solution which is great.
I’d point out though that tribe_get_custom_field() – which does indeed return a string – is a different function from tribe_get_custom_fields() (note the final s in the function name) – which is what you are using in your above example and is correctly documented as returning an array.
Since it sounds like you’re all set in any case I’ll go ahead and close this thread – of course if there is anything else please don’t hesitate to create new threads as needed.
Thanks!
July 7, 2015 at 6:29 am #981896Support Droid
KeymasterThis topic has not been active for quite some time and will now be closed.
If you still need assistance please simply open a new topic (linking to this one if necessary)
and one of the team will be only too happy to help. -
AuthorPosts
- The topic ‘How can I find the name of a custom field?’ is closed to new replies.
