Support

Account

Home Forums ACF PRO custome tinyMCE color picker problem

Unread

custome tinyMCE color picker problem

  • I am trying to create my own colors via acf in the tinymce color picker, but I have a problem with the output.

    
    function wfl_color_picker($init) {
    $custom_colours = array();
    $args = array(
         'post_type' => 'posttype',
         'posts_per_page' => '-1'
    );
    
    $postcolor = new WP_Query($args);
    
    if($postcolor->have_posts()) : 
    while ( $postcolor->have_posts() ) : 
    	$postcolor->the_post(); 
    	array_push($custom_colours, strtoupper(substr( get_field( 'hex' ), 1, 6 ) ) );
    	array_push($custom_colours, get_the_title() );
    endwhile; //end the while loop
    wp_reset_postdata();
    
    $colors = '["'. join("\", \"", $custom_colours) .'"]';
    // build colour grid default+custom colors
    $init['textcolor_map'] = $colors;
    // change the number of rows in the grid if the number of colors changes
    // 8 swatches per row
    $init['textcolor_rows'] = 1;
    return $init;
    endif; // end of the loop. 
    }
    add_filter('tiny_mce_before_init', 'wfl_color_picker');
    

    The function also works. But when I do the while query then my post is in the beckend without content elements.

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.