Title: Using Custom fields &#8211; problem
Last modified: August 30, 2016

---

# Using Custom fields – problem

 *  Resolved [Bloomhash](https://wordpress.org/support/users/bloomhash/)
 * (@bloomhash)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/using-custom-fields-problem/)
 * Hello!
 * I followed instructions on Injecting Custom PHP Code into Templates ([http://time.ly/document/user-guide/customize-calendar/injecting-custom-php-code-templates/](http://time.ly/document/user-guide/customize-calendar/injecting-custom-php-code-templates/))
   and have some problems.
 * For **Agenda** I want to use several custom fields.
 * I started with:
 *     ```
       add_filter( 'ai1ec_theme_args_agenda.twig', 'mytheme_agenda_args', 10, 2 );
       /**
        * Adds value of custom field to event arrays in Agenda view.
        *
        * @param  array $args     Arguments passed to the agenda.twig template
        * @param  bool  $is_admin Whether this is an admin-area template
        * @return array           Modified $args array
        */
       function mytheme_agenda_args( $args, $is_admin ) {
         // Iterate through every date of Agenda view.
         foreach ( $args['dates'] as $date => &$date_info ) {
           // Iterate through the "all-day" and "not all-day" categories of that day.
           foreach ( $date_info['events'] as &$category ) {
             // Iterate through every event of the current category.
             foreach ( $category as &$event ) {
               $post_id      = $event->get( 'post_id' );
               $rating = get_post_meta( $post_id, 'rating', true );
               // Add value of custom field to event entity to be used in template.
               $event->set( 'rating', $rating );
               $buyid = get_post_meta( $post_id, 'buyid', true );
               $event->set( 'buyid', $buyid );
             }
           }
         }
   
         return $args;
       }
       ```
   
 * and have problem with **buyid**. Returns nothing.
    No problem with **rating**,
   no problem with using both of them in **single event view**.
 * [https://wordpress.org/plugins/all-in-one-event-calendar/](https://wordpress.org/plugins/all-in-one-event-calendar/)

Viewing 1 replies (of 1 total)

 *  Thread Starter [Bloomhash](https://wordpress.org/support/users/bloomhash/)
 * (@bloomhash)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/using-custom-fields-problem/#post-6823049)
 * Sorry, my fault.
 * Need to call it via event.get().
    **Example: {{ event.get( ‘rating’ ) }}**

Viewing 1 replies (of 1 total)

The topic ‘Using Custom fields – problem’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/all-in-one-event-calendar.svg)
 * [Timely All-in-One Events Calendar](https://wordpress.org/plugins/all-in-one-event-calendar/)
 * [Support Threads](https://wordpress.org/support/plugin/all-in-one-event-calendar/)
 * [Active Topics](https://wordpress.org/support/plugin/all-in-one-event-calendar/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/all-in-one-event-calendar/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/all-in-one-event-calendar/reviews/)

## Tags

 * [custom fields](https://wordpress.org/support/topic-tag/custom-fields/)
 * [php](https://wordpress.org/support/topic-tag/php/)

 * 1 reply
 * 1 participant
 * Last reply from: [Bloomhash](https://wordpress.org/support/users/bloomhash/)
 * Last activity: [10 years, 6 months ago](https://wordpress.org/support/topic/using-custom-fields-problem/#post-6823049)
 * Status: resolved