• Home
  • WordPress Maintenance & Support
  • Pricing
  • My Account
  • Home
  • WordPress Maintenance & Support
  • Pricing
  • My Account
home/Knowledge Base/Wordpress/How to add new column on a custom post type in WordPress back-office?
Popular Search:Wordpress white screen

How to add new column on a custom post type in WordPress back-office?

9 views 0 October 16, 2022 info_c0xde61d

       // Add the custom columns
        add_filter( 'manage_ogpqrcode_posts_columns',  'set_custom_columns' );
	function set_custom_columns($columns) {
	    unset( $columns['author'] );
	    $columns['ref_name'] = __( 'Ref', 'your_text_domain' );
	    $columns['qr_code'] = __( 'QR Code', 'your_text_domain' );

	    return $columns;
	}

	// Add the data to the custom columns 
        add_action( 'manage_ogpqrcode_posts_custom_column' ,  'custom_column', 10, 2 );
	function custom_column( $column, $post_id ) {

		$product_ref = get_field('ref_produit', $post_id);
		$post_slug = get_post_field( 'post_name', $post_id );


		$imgfilename = plugin_dir_url( __FILE__ ). "qrcode-img/".$product_ref."-".$post_slug.".png";
	
	    switch ( $column ) {

	        case 'ref_name' :

	        	echo $product_ref;
	            break;

	        case 'qr_code' :
	           	
	           	echo '<a href="'.$imgfilename.'" target="_blank">Télécharger</a>';
	       		//echo $imgfilename;
	            break;

	    }
	    
	}
Tags:wordpresscustom post type

Was this helpful?

Yes  No
Related Articles
  • How to Fix “Briefly Unavailable For Scheduled Maintenance. Check Back in a Minute.”
  • How to add new column on a custom post type in WordPress back-office?
  • How to create a custom post type in wordpress ?
  • How can I get help with WordPress?

Didn't find your answer? Contact Us

Wordpress
  • How to add new column on a custom post type in WordPress back-office?
  • How to Fix “Briefly Unavailable For Scheduled Maintenance. Check Back in a Minute.”
  • How to add new column on a custom post type in WordPress back-office?
  • How to create a custom post type in wordpress ?
  • How can I get help with WordPress?
KB Categories
  • Wordpress
  • WooCommerce
  • Domain name & Hosting

  How to create a custom post type in wordpress ?

How can I get help with WordPress?  

WooHelp offer professional WordPress, WooCommerce assistance and WordPress support by our expert developers. We will do backups, updates, security, speed optimization and create custom plugins. We also offer fast WordPress fix services for any emergency.

Support Links
  • FAQ
  • Forums
  • KnowledgeBase
  • Documentation
Useful Help Links
  • Community Home
  • Item support
  • Refunds
  • Market API
  • Privacy Policy
  • Terms of Use
  • Copyright 2022 WooHelp - Wordpress WooCommerce Developer.

Popular Search:Wordpress white screen