0

How can I access the loop that displays all the custom posts in a custom post type's edit.php page? Is there some sort of hook for this?

I want to do some condition checking on the data that is being pulled during the loop and it doesn't seem like WP offers any obvious solution.

  • What do you mean by "custom posts"? – s_ha_dum Apr 25 '13 at 21:10
1

Yes there is some sort of hook for this: manage_posts_custom_column

Pseudo code:

function my_cpt_custom_column( $column ) {
    global $post;
    if ( 'my_cpt' == get_post_type( $post ) ) {
        switch ( $column ) {
            case 'title':
                // do stuff with $post->post_title
                echo $post->post_title;
                break;
            case 'some-other-heading':
                // do stuff
                break;
        }
    }
}

add_action( 'manage_posts_custom_column', 'my_cpt_custom_column' );

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.