0

I have a custom post type, when I view my posts of this type in the dashboard I see: Title Author Date Added as well as a few more I have added

My question is how can I display (like the author column) the user which approved/published the post

Ideally I would like to be able to click on the name and view the publishers published posts

function my_manage_product_columns( $column, $post_id ) {
global $post;

switch( $column ) {


    case 'publisher' :

        $publisher = get_the_modified_author();

    $link = sprintf( '<a href="%s">%s</a>',
            esc_url( add_query_arg( array( 'post_type' => 'product', 'genre' => $term->slug ), 'edit.php' ) ),
            esc_html( sanitize_term_field( 'name', $term->name, $term->term_id, 'genre', 'display' ) )
           )
        echo $link;

    break;

    /* Just break out of the switch statement for everything else. */
    default :
    break;
}
}

add_action( 'manage_product_posts_custom_column', 'my_manage_product_columns', 10, 2 );

I found an example online sorting by genre but I don't know how to modify it (what to replace the variables with)

'genre' => $term->slug 
 $term->name
 $term->term_id

1 Answer 1

0

get_the_modified_author(); isn't going to tell you who published the post, just who last edited it. You will need to capture you publisher yourself.

function post_published_notification( $ID, $post ) {
  $publisher = wp_get_current_user();
  update_post_meta($ID,'my_publisher',$publisher);

}
add_action( 'publish_post', 'post_published_notification', 10, 2 );

Then use get_post_meta($post_id,'my_publisher') to retrieve the data.

Of course there are a numerous ways to fine tune this. Do you want to only save the publisher the first time it is published, in those cases where that can occur? Etc.

1
  • My question is more directed towards making this authors name click-able to show all the posts they modified. For the part that you answered I would rather not use custom fields as they can be modified. Can I get a list of authors from the revisions??
    – Oliver
    Commented Jul 25, 2015 at 22:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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