0

I'm using Pods plugin (ver 2.2) to create some 'Pods' or Advanced Content Types, as they would refer to it, which are like custom post types but are actually separate from WP, blank slate, in their own tables. Each content type has at least two fields.

What I wanted to know is how do I display those field inputs in the manage page columns of those Advanced Content Types (created with the Pods interface)? By default it is only showing one column, ie. the default field.

Using manage_${post_type}_posts_columns doesn't seem to work since they're not really post types.

Further research lead me to pods_ui(), but the result is undesirable: the list is blank (pic #1) and there seems to be another Pod item(?) at the bottom (pic #2).

Effort #1

This was the code:

function pods_ui_test() {
    $object = pods('cities');
    $object->ui = array(
            'columns' => array(
                    'cities'    => 'Cities',
                    'regions'   => 'Regions'
                ),
        );

    pods_ui($object, true);
}

add_filter( 'pods_admin_ui_cities', 'pods_ui_test' );

Pic #1:

Blank list

Pic #2:

Bottom part

Anybody familiar with how Pods work?


Effort #2

@ScottKingsleyClark... I think I understand what you mean, so I gave it another shot. Here's the code:

function pods_ui_test($object) {
    $pod = $object[pod];

    // Test on TITLE
    $pod->pod_data[label] = 'XXXXX';

    // Test on UI Column
    $pod->ui = array(
            'columns' => array(
                    'city'      => 'City',
                    'region'    => 'Region'
                )
            );

    return $object;
}

add_filter( 'pods_admin_ui_cities', 'pods_ui_test' );

I tested by changing the title and the column UI to see if it has any effects at all. The former works, ie.the TITLE changed, but the column remains the same, ie. only one is showing which is the default field.

  • 1
    I'm the lead developer of Pods, I'm away from home right now but should be able to respond properly tomorrow. You are using the right hook, but it's a filter so it passes a $ui variable that you change and return, not run another pods_ui. I'll have to look through your code to provide the tweaks you'd need. – Scott Kingsley Clark Feb 4 '13 at 4:04
  • Thanks for the quick reply. I created the pods using the pods built-in interface. So I'm actually trying to add the columns to existing pods. The code above is the only pods-related code that I have. Was I supposed to create the whole Pods programmatically instead of using the interface to have the columns showing correctly? – Giraldi Feb 4 '13 at 6:23
  • @ScottKingsleyClark... I think I understand what you mean, so I gave it another shot. But still it doesn't work. (See updated question) – Giraldi Feb 4 '13 at 12:39
2

To customize which fields are shown in Pods UI, you can filter the default UI options through this filter / function combination. Overriding the $ui array with the options you wish to customize, this can be pretty quick and easy.

function pods_ui_test ( $ui ) {
    // Test on UI Column
    $ui[ 'fields' ][ 'manage' ] = array(
        'city' => 'City',
        'region' => 'Region'
    );

    return $ui;
}

add_filter( 'pods_admin_ui_cities', 'pods_ui_test' );
  • This post was automatically marked as "low quality", probably because it is a block of code with little description. Though it may be obvious to you, and to many here, what this does you could make the answer meaningful to less knowledgeable users by providing a little bit of commentary. – s_ha_dum Feb 4 '13 at 16:15
  • I'll include more explanation when I get some time later today, was just getting him what he needed ASAP. – Scott Kingsley Clark Feb 4 '13 at 16:49
  • @ScottKingsleyClark: Awesome! That worked very well. thank you very much for the quick reply. Really appreciate that! – Giraldi Feb 5 '13 at 2:23
  • @s_ha_dum: I think this answer is completing that which already exists in the question & the comments under it. Most of the details are in there. – Giraldi Feb 5 '13 at 2:25
  • @ScottKingsleyClark Can I add a column using a new name to display a value calculate for each row using the pod id? I mean "new name" as a name of a field that not exist, I want to show a link for each pod in the admin ui calculated by the pod id. – dlopezgonzalez Feb 17 '15 at 13:13
0

this works for me : http://www.deluxeblogtips.com/2010/05/add-custom-column.html

In my case I used this code :

add_filter('manage_edit-projet_columns', 'my_columns');
function my_columns($columns) {
    $columns['categorie'] = 'Catégorie';
    return $columns;
}
add_action('manage_posts_custom_column',  'my_show_columns');
function my_show_columns($name) {
    global $post;
    switch ($name) {
        case 'categorie':
            $views = get_post_meta($post->ID, 'categorie', true);
            echo($views['name']);
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.