Telford 615787
Web Design • Beauty is in simplicity
Like on Facebook Follow on Twitter Follow on Pinterest Connect on LinkedIn

Using Bulk Edit on WP custom post types with multiple select dropdowns

Bulk Edit WP custom post type with multiple select dropdownsI had set up a custom post type on a recent project and added meta boxes to the post and post-new pages.  I then wanted to have the post meta to be editable through Quick Edit and Bulk Edit.  Knowing that someone, somewhere will have come up with a solution, I was pleased to find that Rachel Carden had done just that.

Her code catered for text, radio buttons and select dropdowns.  Perfect, I thought, and indeed the well commented files I downloaded did the job. Sort of.

The Problem

On this particular project, I wanted to add three extra fields to the post list table.  A text field and two select dropdowns.  The problem I had trouble solving was when saving Bulk Edits. The code didn’t seem to cater for when only one select dropdown field was being bulk-edited. I found that, unlike the core select dropdowns, once bulk edit was clicked, there was no – No Change – option presented in the select dropdowns. This meant when the update button was clicked, all select dropdowns would update.

The Solution

The solution I came up with required adding a – No Change – option to select dropdowns only when bulk editing.  By using the current_filter() function I was able to distinguish between quick editing and bulk editing then add the appropriate input element. Like so:

$bulk = strpos(current_filter(), 'bulk') !== '' ? true : false;

When quick editing, the action used is quick_edit_custom_box and returns false, when bulk editing, bulk_edit_custom_box is used and returns true.  It was then quite straight forward emulating core select dropdowns.

by
Sid Edwards

Sid Edwards Web Designer

Sid is Proprietor of tuzongo.com with an interest in helping small and medium-sized enterprises compete with large companies. He has many years experience using coding skills with standard frameworks to create unique award winning websites. You can follow Sid on Twitter, connect on LinkedIn or Like on Facebook.
Using Bulk Edit on WP custom post types with multiple select dropdowns was last modified: October 18th, 2016 by Sid Edwards
Leave a Reply

Are you human? (required)

Latest Posts

  • Sid Edwards Curriculum Vitae
    Curriculum Vitae
    by Sid Edwards Tweet Sid Edwards Web Designer Sid is Proprietor of tuzongo.com with an interest in helping small and...
  • Merry Christmas from TUZONGO Web Design
    Merry Christmas from TUZONGO Web Design
    Wishing peace and goodwill this Christmas to all and a Happy New Year. by Sid Edwards Tweet Sid Edwards Web...

Access

Address

Old Toll Gate, St George's
Telford Shropshire TF2 9FH
Phone: 07899 697 956
Website: tuzongo.com
Email: sid@tuzongo.com

Recent Projects

  • Web Design Promotional Video
    Web Design Promotional Video
    The task was to provide information on what goes into creating a website. Describing the process from start to finish....
  • The PathHeights Brand
    Branding a brand new Band
    The band’s name, The PathHeights, derives from the word Ptahites, meaning spiritual, creative beings conveying a collective conscious message. They...
0