• Resolved Bloomhash

    (@bloomhash)


    Hello!

    I followed instructions on Injecting Custom PHP Code into 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://ww.wp.xz.cn/plugins/all-in-one-event-calendar/

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)

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