showing fields in theme not working
Author | Posts |
---|---|
July 22, 2014 at 10:41 am 23928 | |
RJ | Here is my code: echo get_post_meta( $post->ID, 'sub_category', true ); I've surrounded it with the appropriate php open and close tags and the 'sub-category' is the meta key from my form, but it displays nothing. What am I doing wrong? Thanks for your help!! |
July 22, 2014 at 2:32 pm 23947 | |
Sk | Hello RJ, The code looks ok. if not work, use Thank you. |
July 23, 2014 at 11:43 am 24005 | |
RJ | I’ve checked to make sure that the meta has a value and also checked that the meta key matches with the one I specified. The code is running in the loop. When I do the var_dump, this is what I get: bool(false) This is the complete snippet of code that I have running in the loop at present: echo get_the_term_list( $post->ID, ‘county’, ‘County: ‘, ‘, ‘, ” ); echo get_post_meta( $post->ID, ‘sub_category’, true ) . “This is the category”; The first two items (county and city) display perfectly so I know that $post->ID works. I cannot figure out why the meta from my form isn’t working though. It’s really important that we get this fixed because I am trying to customize my template for the post and this seems to be the only way to do that. |
July 27, 2014 at 1:46 pm 24175 | |
RJ | Ok, so after some experimentation, I have found that for some reason post->ID won’t work. Instead I have to use get_the_ID(). Below is what I ended up with. Is there some reason that post->ID works perfectly for my custom taxonomies, but I have to switch to get_the_ID() for the form’s custom fields? echo get_the_term_list( $post->ID, ‘county’, ‘County: ‘, ‘, ‘, ” ); Thanks! |