• Resolved Julius0range

    (@julius0range)


    I’m using the most recent version of ACF and i’m running into a weird issue. The fields that I created as checkbox, radio buttons or text fields return a value just fine. Fields created as WSYWIG seem to cause an error (Nothing outputs).

    Originally, I was using a function to output tabular data. When that function is called within a template page it works like a charm. When the function is attached to a hook, the WSYWIG values don’t show.

    Thoughts? Code below. tvst_tally works perfectly, where tvst_winner causes a break.

    `

    function tvst_body($groups){
    $body = ‘<tbody>’;
    if(is_array($groups)){
    $index = 0;
    foreach ($groups as $group){
    $body .= tvst_subheader($index);
    // $body .= tvst_row($group, true, ‘l’, ‘light’);
    // $body .= tvst_get_edge($group);
    $index ++;
    }
    }else{
    $body .= tvst_subheader(0);
    // $body .= tvst_row($groups, true, ‘l’, ‘light’);
    // $body .= tvst_get_edge($groups);
    }
    // $body .= tvst_winner();
    $body .= tvst_tally();
    $body .= ‘</tbody>’;
    return $body;
    };

    function tvst_winner(){
    return ‘<tr><td colspan=”2″><p>’ . get_field(‘winner’) . ‘</p></td></tr>’;
    };

    function tvst_tally(){
    global $wpdb, $post;
    //Check the DB for votes
    $result_r1_c1 = $wpdb->get_var( “SELECT COUNT(*) FROM $wpdb->postmeta WHERE post_id = $post->ID AND meta_key LIKE ‘%_r1%’ AND meta_value LIKE ‘combatant 1′”);
    $result_r1_c2 = $wpdb->get_var( “SELECT COUNT(*) FROM $wpdb->postmeta WHERE post_id = $post->ID AND meta_key LIKE ‘%_r1%’ AND meta_value LIKE ‘combatant 2′”);
    $result_r2_c1 = $wpdb->get_var( “SELECT COUNT(*) FROM $wpdb->postmeta WHERE post_id = $post->ID AND meta_key LIKE ‘%_r2%’ AND meta_value LIKE ‘combatant 1′”);
    $result_r2_c2 = $wpdb->get_var( “SELECT COUNT(*) FROM $wpdb->postmeta WHERE post_id = $post->ID AND meta_key LIKE ‘%_r2%’ AND meta_value LIKE ‘combatant 2′”);
    //Append vote name to tally results and display in a cell
    $tally = ‘<tr><td class=”tally_l”><span class=”left”>R1</span><p>’ . get_field(‘combatant_1_name’) . ‘ – ‘ . $result_r1_c1 . ‘; ‘ . get_field(‘combatant_2_name’) . ‘ – ‘ . $result_r1_c2 . ‘</p></td>’;
    $tally .= ‘<td class=”tally_r”><span class=”left”>R2</span><p>’ . get_field(‘combatant_1_name’) . ‘ – ‘ . $result_r2_c1 . ‘; ‘ . get_field(‘combatant_2_name’) . ‘ – ‘ . $result_r2_c2 . ‘</p></td></tr>’;
    return $tally;
    };

Viewing 1 replies (of 1 total)
  • Thread Starter Julius0range

    (@julius0range)

    I have it working, but I had to replace the ACF native function get_field() with the WP function get_post_meta(). Works like a charm now

Viewing 1 replies (of 1 total)
  • The topic ‘ACF Values submitted via WSYWIG cause error’ is closed to new replies.