As for the other issue you are mentioning, well is not really an issue since if you change the field from one type to another only the type is changing and not the field ID. Anyway note that you can't change a text field into a dropdown or vice versa. You can change fields of the same family ( yeah, I know, I made that up :) ) textfield <-> textarea ; radio <-> checkbox <-> dropdown <-> multidropdown
Okay, I can update a Custom Field after it's been created now, but Dropdown Select Box still fails to output any data to the page.
I made a Custom Field called "Days of the Week" with each day of the week entered into a field for the dropdown.
I then copied the code for this new Custom Field, and placed it into the loop, along with the other Custom Fields that I created (and which DO output their data to the page); see below example
<p>Day of Week:<?php if ( get_post_meta( $post->ID, '_ct_selectbox_4d58b4c102902', true ) ) { foreach ( get_post_meta( $post->ID, '_ct_selectbox_4d58b4c102902', true ) as $value ) { echo $value . ', '; }} ?></p>
So my main issue still exists: Custom Fields with a Field Type of "Text Box", "Multi-line Text Box", "Checkbox" WILL output their data to the page using the supplied embed code.
But Custom Fields with a Field Type of "Dropdown Select Box" WILL NOT output any data.
But the Field Types entered in the Admin for this Custom Field are; Monday, Tuesday, Wednesday, Thursday, Friday, Saturday -- with Tuesday selected as default.
Unfortunately, this is in a test site that I cannot show.
So what I'll do later on, is provision another cpanel account on my system, and set up a fresh Wordpress install, and let you guys have access to it all.
Well, thats exactly what it should return on the front page if the field is a "Dropdown". This is the value of the Custom Field.
If you want to output multiple values from a single Custom Field on front you have to use "Multi Select Box".
But the Field Types entered in the Admin for this Custom Field are; Monday, Tuesday, Wednesday, Thursday, Friday, Saturday -- with Tuesday selected as default.
The "Dropdown" itself appears in admin in the Custom Fields section of the post_type you've attached it to.
I can see all six days (Monday, Tuesday, Wednesday, Thursday, Friday, Saturday) in the DB when I look there in the WP_OPTIONS table.
Not sure whether we are on the same page here, but the options for the Custom Fields appear in admin and the values set in admin appear on front ( using the embed code to output them ).
If you tell me exactly what you are trying to achieve I can suggest the best way you can do it.
@KennethFeldman, then you should just use the following to display the day: <?php echo get_post_meta( $post->ID, '_ct_selectbox_4d58b4c102902', true ); ?>
With the foreach you are trying to display the values of an array, but since the contents of that custom field isn't an array it won't output anything inside the foreach-loop. Thus just echo'ing the contents of the custom field does do what you want.
That is exactly what this plugin is giving me to paste into my template.
If what Hiranthi has sent me to use is what I am SUPPOSED to be using, then the plugin has a bug in it, where it provides the incorrect EMBED CODE for me to use.
Responses (13)
Sales & Support Lead — 12th February 2011 (1 year ago) #
Hiya Kenneth,
First off, welcome to WPMU DEV!
Are you editing this with the role of 'Super Admin' or something else? We'll take another look at this and help ya get it sorted.
Thanks!
Member — 12th February 2011 (1 year ago) #
Hi,
This is a regular install of Wordpress (not multi-user).
I'm logged in with user role: Administrator
WP 3.0.5, TwentyTen Theme
Only CustonPress and the WPMU DEV Update Notifications plugins active.
CustomPress Version 1.1.0
Developer — 14th February 2011 (1 year ago) #
Hi Kenneth,
Thanks for reporting this. Bug fixed. You can update through the Update Notifications plugin or manually - here is the download http://premium.wpmudev.org/project/custompress
As for the other issue you are mentioning, well is not really an issue since if you change the field from one type to another only the type is changing and not the field ID. Anyway note that you can't change a text field into a dropdown or vice versa. You can change fields of the same family ( yeah, I know, I made that up :) ) textfield <-> textarea ; radio <-> checkbox <-> dropdown <-> multidropdown
Member — 14th February 2011 (1 year ago) #
Um, well...
Okay, I can update a Custom Field after it's been created now, but Dropdown Select Box still fails to output any data to the page.
I made a Custom Field called "Days of the Week" with each day of the week entered into a field for the dropdown.
I then copied the code for this new Custom Field, and placed it into the loop, along with the other Custom Fields that I created (and which DO output their data to the page); see below example
<p>Day of Week:<?php if ( get_post_meta( $post->ID, '_ct_selectbox_4d58b4c102902', true ) ) { foreach ( get_post_meta( $post->ID, '_ct_selectbox_4d58b4c102902', true ) as $value ) { echo $value . ', '; }} ?></p>
So my main issue still exists: Custom Fields with a Field Type of "Text Box", "Multi-line Text Box", "Checkbox" WILL output their data to the page using the supplied embed code.
But Custom Fields with a Field Type of "Dropdown Select Box" WILL NOT output any data.
Please advise.
Member — 14th February 2011 (1 year ago) #
This website is messed up -- it triple posted my reply.
Member — 14th February 2011 (1 year ago) #
What is returned when you add this to your template?
<?php print_r(get_post_meta( $post->ID, '_ct_selectbox_4d58b4c102902', true )); ?>Member — 14th February 2011 (1 year ago) #
It just returns "Wednesday"
But the Field Types entered in the Admin for this Custom Field are; Monday, Tuesday, Wednesday, Thursday, Friday, Saturday -- with Tuesday selected as default.
Unfortunately, this is in a test site that I cannot show.
So what I'll do later on, is provision another cpanel account on my system, and set up a fresh Wordpress install, and let you guys have access to it all.
I'll post back with this new account later on.
Member — 14th February 2011 (1 year ago) #
FYI: I can see all six days (Monday, Tuesday, Wednesday, Thursday, Friday, Saturday) in the DB when I look there in the WP_OPTIONS table.
Developer — 14th February 2011 (1 year ago) #
Hi Kenneth,
Well, thats exactly what it should return on the front page if the field is a "Dropdown". This is the value of the Custom Field.
If you want to output multiple values from a single Custom Field on front you have to use "Multi Select Box".
The "Dropdown" itself appears in admin in the Custom Fields section of the post_type you've attached it to.
Not sure whether we are on the same page here, but the options for the Custom Fields appear in admin and the values set in admin appear on front ( using the embed code to output them ).
If you tell me exactly what you are trying to achieve I can suggest the best way you can do it.
Member — 14th February 2011 (1 year ago) #
@KennethFeldman, then you should just use the following to display the day:
<?php echo get_post_meta( $post->ID, '_ct_selectbox_4d58b4c102902', true ); ?>With the foreach you are trying to display the values of an array, but since the contents of that custom field isn't an array it won't output anything inside the foreach-loop. Thus just echo'ing the contents of the custom field does do what you want.
Member — 14th February 2011 (1 year ago) #
Well, that does work, Hiranthi.
But the confusing thing for me is that when I click the EMBED CODE link in the CUSTOM FIELDS list, it gives me the following --- which does not work:
<?php if ( get_post_meta( $post->ID, '_ct_selectbox_4d58b4c102902', true ) ) { foreach ( get_post_meta( $post->ID, '_ct_selectbox_4d58b4c102902', true ) as $value ) { echo $value . ', '; }} ?>
That is exactly what this plugin is giving me to paste into my template.
If what Hiranthi has sent me to use is what I am SUPPOSED to be using, then the plugin has a bug in it, where it provides the incorrect EMBED CODE for me to use.
Developer — 14th February 2011 (1 year ago) #
Hi Kenneth,
Strange, you should get an array with a single value in it. That's why there is a "foreach" Loop there. I will investigate things further.
Sales & Support Pro — 23rd February 2011 (1 year ago) #
Hi Ivan,
Any update on this?
Kenneth - is this still an issue for you?
Phil
Become a member