PHP code example of keironlowe / posty

1. Go to this page and download the library: Download keironlowe/posty library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

keironlowe / posty example snippets


Posty\Posty::make('Product', 'Products')->register();

Posty\Posty::make('Product', 'Products')
    ->setLabels()
    ->setArguments()
    ->register();

Posty\Posty::make('Product', 'Products')
    ->setLabels([
        // All labels
    ])
    ->register();

Posty\Posty::make('Product', 'Products')
    ->setLabels(function ($labels) {
        $labels['menu_name'] = 'Overwrite value'

        return $labels;
    })
    ->register();

$products = Posty\Posty::make('Product', 'Products');
$columns  = $products->columns();

$columns->add([
    [
        'label' => 'Price'
        'value' => fn (int $post_id) => get_field('price', $post_id)
        'order' => 2,
        'sort'  => 'numeric'
    ],
    [
        'label' => 'Image'
        'value' => fn (int $post_id) => get_field('image', $post_id)
        'order' => 3,
        'id'    => 'alternate_image',
        'sort'  => 'alpha'
    ]
]);

$columns->add(function (array $existingColumns) {
    // Return column array
});

$columns->remove(['author', 'date']);

$columns->reorder(['cb', 'title', 'price', 'image']);