• Resolved gary_sweetman

    (@gary_sweetman)


    Hi,

    I wondered if you can help me because I’m thinking that I may need a different call to display the selected custom checkbox field in admin, the column shows as does the “-” when the field is empty, however it will not show the actual selected field when it isn’t, so I thought perhaps it may need a slight tweak with it being a checkbox over a text field?

    Here’s what I have

    add_filter("manage_edit-advert_columns", "seller_type", 20);
    function seller_type( $columns ) {
        $columns["seller_type"] = "Seller Type";
        return $columns;
    }
    add_action("manage_advert_posts_custom_column", "ad_seller_type", 10, 2);
    function ad_seller_type( $column, $post_id ) {
        if($column == "seller_type") {
            $cf = get_post_meta( $post_id, 'seller_type', true );
            if(empty($cc)) {
                echo "<em>-</em>";
            } else {
                echo "<strong>".$cc."</strong>";
            }
        }
    }

    And I think it may be this bit which needs editing (but I’m no expert and I wouldn’t know what it might need editing to)
    echo "<strong>".$cc."</strong>";

    Thank you

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

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

    (@gwin)

    In function ad_seller_type you do not have $cc variable, only $cf, so your if statement should be

    if(empty($cf)) {
                echo "<em>-</em>";
            } else {
                echo "<strong>".$cf."</strong>";
            }
    Thread Starter gary_sweetman

    (@gary_sweetman)

    Thank you – That has sorted it!

    My reasoning is that you used $cc in the “show details on ad details page” section, and I found that by using all 4 fields as $cf there the same result was diplayed on all fields so I used different ones for each option and gave them their function in that section so thought I could do the same for the admin part. My mistake and thank you for setting me straight!

    Marking as resolved.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘custom field not showing properly in admin’ is closed to new replies.