• Resolved MyCoach

    (@bernard77176)


    Hello Greg,

    Is it possible to add a category column in the admin panel ads?
    I looked at this possibility via a filter, but I do not know to associate the category, advert_category;
    This possibility is interesting, not urgent, but useful !!!!
    thank you beforehand
    See you soon

    bernard

    https://www.ads-software.com/plugins/wpadverts/

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

    (@gwin)

    Hi,
    i suppose this will be pretty much like any other field to the list in wp-admin / Classifieds panel, see chapter “Displaying Custom Field in wp-admin List” here https://wpadverts.com/documentation/custom-fields/

    There is a code which shows how to display value of a meta field, but with some PHP and WordPress API knowledge it should be possible to easily modify to display category value.

    Thread Starter MyCoach

    (@bernard77176)

    Good evening Greg, and thank you for your answer,

    But my English is very bad, I used the automatic tradution me and I fear that you do not understand my request.

    I would actually have the list of all ads like

    currently in : wp-admin/edit.php?post_type=advert

    Author Title Price Date Expires

    My request, with an additional category column

    Title Category Author Price Date Expires

    I hope I have explained more clearly

    Thank you

    Plugin Author Greg Winiarski

    (@gwin)

    Hi, this article actually explains what you are asking about, but like i wrote earlier it requires some custom programming, i modified the code for you, paste it in your theme functions.php it will add the Category column to the list

    add_filter("manage_edit-advert_columns", "my_adverts_edit_columns_category", 20);
    
    function my_adverts_edit_columns_category( $columns ) {
        $columns["advert_category"] = "Category";
        return $columns;
    }
    
    add_action("manage_advert_posts_custom_column", "my_adverts_manage_post_columns_category", 10, 2);
    
    function my_adverts_manage_post_columns_category( $column, $post_id ) {
        if($column == "advert_category") {
            $advert_category = get_the_terms( $post_id, 'advert_category' );
            if( empty( $advert_category ) ) {
                echo "-";
            } else {
                foreach( $advert_category as $c ) {
                    echo $c->name . "<br/>";
                }
            }
        }
    }
    Thread Starter MyCoach

    (@bernard77176)

    Hi Greg,

    You’re great, that’s exactly what I wanted, it’s great.

    It was not super important, but it will be more convenient, for what I am setting up.

    Thanks again,

    See you very soon

    Bernard

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Custom column in admin’ is closed to new replies.