WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Return checkbox value in column (3 posts)

  1. Archie22is
    Member
    Posted 1 year ago #

    Hi guys,

    I want to return a checkbox value in a column layout. I am currently able to return normal fields using the function below:

    add_action('manage_posts_custom_column', 'my_show_columns');
    function my_show_columns($name) {
    	global $post;
    	switch ($name) {
    
    		case 'telephone':
    			//echo "telephone";
    			$telephone_number = get_post_meta($post->ID, 'telephone_number', true);
    			echo $telephone_number;
    			break;
    
    		case 'email_address':
    			$email_address = get_post_meta($post->ID, 'email_address', true);
    			echo '<a href="mailto:' . $email_address . '">' . $email_address . '</a>';
    			break;		
    
    		case 'featured':
    			$featured = get_post_meta($post->ID, 'featured', true);
    			echo $featured; // returns nothing
    			break;
    	}
    }

    The featured field in this case is a radio button value (Yes/No) taken care of by a custom post type (using the Pods Framework). I wish to return either value that is selected / checked. How will I go about doing that?

    Thank you in advance

  2. Scott Kingsley Clark
    Member
    Posted 1 year ago #

    I suggest you use a plugin like CodePress Admin Columns

    http://wordpress.org/extend/plugins/codepress-admin-columns/

    It integrates with Pods and makes this sort of thing pretty easy.

    Otherwise, you could maybe consider this code:

    $featured = pods_field_display( $post->post_type, $post->ID, 'featured' );

  3. Archie22is
    Member
    Posted 1 year ago #

    Thanks Scott!

Topic Closed

This topic has been closed to new replies.

About this Topic