post meta – Newly published custom types show up in database but don’t appear in the postmeta meta_value array
I inherited a WordPress website with a custom post type, Business Types. I created a template page to display each business type (i.e. Construction, Lodging, Dining, etc.) as a heading with all the businesses in that category listed under it. If I add a new business, select a checkbox for one of the existing categories, and publish it, it shows up in that list. However, when I try to add a new business type, it does not show up.
The newly added business types show up in the database with a name, slug, term_id, and an object_id for each business of that type. But in the post_meta, when I filter by the post_id of the business page, I can see that the meta_value does not include any of the newly added business types.
Is this something that needs to be updated with a custom function? I believe it was working before I inherited the website, but maybe it was just overlooked. My gut feeling is that I need to use some custom code to let the Business page “know” about the newly added types, and if that’s the case, I would really appreciate some guidance with that.
In the Businesses template page, this is the line of code I use to retrieve the business types data. It returns the previously created business types, but no newly created ones:
$business_types = get_post_meta($post->ID, 'business_types', true);
And this is the existing code in functions.php to register the business post and taxonomy type:
// businesses
register_post_type('businesses', array(
'label' => 'Businesses',
'public' => true,
'_builtin' => false,
'show_ui' => true,
'capability_type' => 'post',
'hierarchical' => false,
'rewrite' => array('slug' => 'member'),
'query_var' => true,
'supports' => array('title','editor','excerpt','trackbacks','custom-fields','comments','revisions','thumbnail','page-attributes',)) );
// business types
register_taxonomy(
'business-types',
array('businesses'),
array(
'can_export' => true,
'hierarchical' => true,
'label' => 'Business Types',
'show_ui' => true,
'query_var' => true,
'rewrite' => array('slug' => 'other-business-types'),
'singular_label' => 'Business Type')
);
Thank you in advance for any help with this!
Leave an answer