Array shows up in some instance, empty in others
-
I’ve added a select advanced box used to associate one custom post type item with other items of a different type.
For example, for a certain INDUSTRY the clients would recommend certain SERVICES.
Here’s how I’ve registered it to show under industry:
array( 'name' => __( 'Services we recommend', 'your-prefix' ), 'id' => "{$prefix}service_rec", 'type' => 'post', 'post_type' => 'service', 'field_type' => 'select_advanced', 'placeholder' => __( 'Select an Item', 'your-prefix' ), 'multiple' => true, 'query_args' => array( 'post_status' => 'publish', 'posts_per_page' => - 1, ), ),
And I’m showing it on the front end like this:
$services = rwmb_meta('as_service_rec'); if ( !empty($services) ) { echo '<ul>'; foreach ($services as $service) { $page = get_post($service); echo '<li>' . $page->post_title . '</li>'; } echo '</ul>'; }
The problem is that this works successfully on any single industry page, but the array shows up EMPTY (testing with print_r) when I try to include this in a wp_query loop elsewhere on the site.
Driving me crazy!
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Array shows up in some instance, empty in others’ is closed to new replies.