• Hi again.
    I wrote 2 small functions, which add the shortcode for each crossword in the crosswords table.
    If you wish you can add them into the next update.

    add_filter('manage_wha_crossword_posts_columns', 'wha_crossword_head');
    function wha_crossword_head( $defaults ) {
        foreach($defaults as $key=>$value) {
            if($key=='date') {  // when we find the date column, add the shortcode column before it. 
               $new['shortcode'] = 'Shortcode';
            }    
            $new[$key]=$value;
        }  
    
        return $new;  
    }
    
    add_action( 'manage_wha_crossword_posts_custom_column', 'wha_crossword_content', 10, 2 );
    
    function wha_crossword_content( $column_name, $post_id ) {
        if ($column_name == 'shortcode') {
           echo '<div class="shortcode">[game-crossword id="' . $post_id . '" ]</div>';
        }
    }

    Bests Lena

  • The topic ‘Shortcodes in crosswords table: Suggestion code’ is closed to new replies.