I'm recreating the classic game 'Snake'. My idea is to firstly make a grid of 50 x 50 cells where each cell is a label of 10 x 10 pixels. 

However, I can't get this to work. I'm using GridLayout but somehow this doesn't really work, as I apparently can't set the site of each grid. 

I watched a video on Youtube where a guy made a tic tac toe game in which each the size of each grid automatically adapted to the size of the added images. What should I do if I use labels instead of images? 

Basically, what should I do to make each cell 10 by 10 pixels big, and put them in a grid of 50x50 cells?

```
import java.awt.*;
import javax.swing.*;

public class MainSnake {
    JFrame frame;
    JLabel[][] cells;

MainSnake() {
    //Frame initializion
    frame = new JFrame("Snake");
    frame.getContentPane().setBackground(Color.BLACK);
    frame.setSize(500, 500);
    frame.setVisible(true);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setResizable(false);
    frame.setLayout(new GridLayout(50, 50));

    createCells();

} //End MainSnake

public static void main(String[]a) {
    new MainSnake();
} //End main

public void createCells(){
    int a = 0;
    int i;
    cells = new JLabel[50][50];
    for (i = 0; i < 50; i++){
        if(i < 50){
            cells[i][a] = new JLabel("");
            cells[i][a].setOpaque(true);
            cells[i][a].setBackground(Color.white);
            cells[i][a].setBorder(BorderFactory.createLineBorder(Color.BLUE, 1));
            cells[i][a].setPreferredSize(new Dimension(10,10));
            frame.add(cells[i][a]);
        } if(i==49){
              i = 0;
              aa++;
        }
    } //End for
}

} //End Class

```

This is what I get (I only added the borders to ble able to see how each cell looks like):

![enter image description here](https://i.stack.imgur.com/AKFNY.jpg)
['https://Stackoverflow.com/questions/26469017', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/4017593/']
I found an solution my self, and sharing it here for some one else to use. The following codes should be placed inside the Wordpress loop.

```
                <?php $fields = get_field('relationship_field_name'); ?>

                <?php if( $fields ): ?>
                    <?php foreach( $fields as $field ): ?>

                        <?php $name = get_field('field_name', $field->ID); ?>
                        <?php $image = get_field('field_name', $field->ID); ?>
                        <?php $email = get_field('field_name', $field->ID); ?>
                        <?php $phone = get_field('field_name', $field->ID); ?>

                        <h4><span><?php echo $name; ?></span></h4>

                        <img style="width: 150px; height: auto;" src="<?php echo $image; ?>" alt="<?php echo $name; ?>"/>

                        <ul class="fa-ul pad10">
                            <li><i class="fa-li fa fa-phone colour"></i><a href="tel:0045<?php echo str_replace(' ', '', $phone); ?>">+ 45 <?php echo $phone; ?></a></li>
                            <li><i class="fa-li fa fa-envelope colour"></i><?php echo $email; ?></li>
                        </ul>

                        <div class="pad10"></div>

                    <?php endforeach; ?>
                <?php endif; ?>

```
I understand, you want to set connection two different post types. You can this with custom fields. Create a selectbox and there options is post of your other custom post type.
For be easy you can use Rilwis's meta box plugin (<https://github.com/rilwis/meta-box>).

Your option value must post id. If you want get selected post, can use this:

```
$getIdWithField = get_post_meta($post->ID, 'custom_personel_field', true);
$post = get_post($getIdWithField);

```