• Resolved aseverirene

    (@aseverirene)


    Hi there,

    Great plugin.

    I would like to see as follows but my code is failing, as it is not working:

    // Add to admin post column
    add_filter( 'manage_posts_columns', 'posts_column_likes' );
    add_action( 'manage_posts_custom_column', 'posts_custom_column_likes', 5, 2 );
    
    function posts_column_likes( $defaults ) {
        $defaults ['oacs_spl_get_like_count( $like_count )'] = __('Likes');
        return $defaults;
    }
    function posts_custom_column_likes( $column_name, $post_id ){
      if ( $column_name === 'Likes' ) {
    echo $oacs_spl_get_like_count($like_count);
    }
    }

    Can you please provide some assistance?

    Warm regards,

    Irene

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author oacstudio

    (@oacstudio)

    Hi Irene,

    Thanks for reaching out and providing your code. Here is a version that works for us:

    // Add to admin post column
    add_filter( 'manage_posts_columns', 'posts_column_likes' );
    add_action( 'manage_posts_custom_column', 'posts_custom_column_likes', 5, 2 );
    
    function posts_column_likes( $columns ) {
        $columns['oacs_likes'] = __('Likes'); // Use a simple string as the column key
        return $columns;
    }
    
    function posts_custom_column_likes( $column_name, $post_id ) {
        if ( $column_name === 'oacs_likes' ) { // This should match the key set in posts_column_likes
            $like_count = get_post_meta( $post_id, '_oacs_spl_post_like_count', true );
            echo esc_html( $like_count ); // Ensure the output is escaped for security
        }
    }

    Kind regards,

    Thread Starter aseverirene

    (@aseverirene)

    Oh… brilliant. Thanks ever so much. It’s working already in my posts dashboard… How can I possibly thank you??

    Warm regards,
    Irene

    Plugin Author oacstudio

    (@oacstudio)

    Nice. Could I ask you for a plugin rating in return?
    All the best!

    Thread Starter aseverirene

    (@aseverirene)

    Sure… Will do.

    Thanks again.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Admin scores’ is closed to new replies.