WordPress.org

Forums

Custom columns shown in post overview (2 posts)

  1. dveat
    Member
    Posted 1 year ago #

    Hi all,

    I have an issue that I can't seem to resolve. A friend is running a WordPress site in combination with Shopperpress as a shop. He had that developped a couple of years ago, but isn't satisfied with the result, so I am trying to fix things for him.

    Anyway, the shop now works well, however there are thousands of products (posts) in the shop and edditting can be a pain. Therefore we'd like to add extra columns to the overview. The data for those columns are in the MySQL table wp_posts, just like most other columndata such as posttitle. The previous developer succeeded there partially. However:

    1. I'd like to add more columns (also in the same table as wp_posts) e.g. SKU

    2. When I click filter, all extra columns get lost and I get the standard overview. I would like to add the custom columns there as well.

    I've searched a long time, but I simply can't find the files to edit. I assume there is some file generating both tables / columns and I guess there is some class / function fetching the results from the query. But I am lost.

    Could anyone direct me to the files to get started?

    Thanks in advance.

  2. bcworkz
    Member
    Posted 1 year ago #

    I hope you were not planning on editing core WP files, that would be the wrong approach. The current custom columns were not implemented properly, otherwise they would appear in all filter views. Thus you need to edit out whatever implementation exists and correctly implement the columns. If they were done by editing core files, simply upload fresh unaltered files.

    If the code is in plugin or theme files, maybe you can use debug_backtrace() to identify where calls are coming from after inducing an error with user_error(). Of course you need to know where to induce an error in the first place. You might try somewhere in the single_row() method in wp-admin/includes/class-wp-posts-list-table.php (line 473) as a start.

    The correct implementation is as a plugin, though editing functions.php of a child theme is a possibility. For proper documentation, the Codex is somewhat lacking, but try Plugin_API/Action_Reference/manage_posts_custom_column and any related links. Also check out Custom Columns for Custom Post Types and Modifying Administration Tables.

Topic Closed

This topic has been closed to new replies.

About this Topic