You can achieve this by using the array_splice() function in conjunction with array_merge(). Here is an example:
function add_new_job_application_status( $statuses ) {
return array_merge(
array_splice( $statuses, 0, 1 ),
array( 'example' => _x( 'Example', 'job_application', 'wp-job-manager-
applications' ) ),
array_splice( $statuses, 1, -1 )
);
}
add_filter( 'job_application_statuses', 'add_new_job_application_status' );
This function takes the first item in the $statuses array, your custom example field, the rest of the items in the array and merges it together. You need to do it this way as splice doesn’t support inserting a multi-dimensional array at a specific point in an array. Hope that helps.
Related Posts:
- Earliest hook to reliably get $post/$posts
- How to pass/get data to/from the WooCommerce data-product_variations object?
- What does (10, 2) mean when used with add_filter
- Clarification on filters and hooks
- How to check if a hook is hooked or not?
- Passing Additional Parameters to add_filter Callable
- Modify WordPress Rest Api Request/Response
- How to add some custom HTML into wordpress admin bar?
- Custom theme hooks / filters – passing arguments
- How to hook wp_list_pages?
- How to make post and comment count unclickable with dashboard_glance_items hook
- How to use the_excerpt in a filter hook?
- Hook into admin post list page
- How can I hide all posts that don’t have a thumbnail?
- Change text of Description in Image Library
- Am I using the right hook for removing quicktags on the admin TinyMCE?
- About Hooks and Filters
- Add Dropdown menu using “add_filter => wp_nav_menu_items”
- Should I use add_action(‘publish_post or add_filter(‘publish_post?
- Add filter to wp_dropdown_pages() or wp_dropdown_categories() – no select container?
- How to get list of all hooks of current theme / plugin?
- What hook/filter can I use to add/edit/show/hide the title under (on hover) links on the table view?
- Change WordPress RSS link with filter?
- Add a header before fields added with the attachment_fields_to_edit() filter
- Hide content editor for posts after approriate date
- Search results sorted by post types
- Why my admin doesn’t work after adding rest_prepare_post filter?
- add_filter() function misunderstanding
- Same Conditionals Not Working on Two Different Hooks
- Filter or Hook to catch pre-rendering of post content
- Can the wp_filter object hold multiple values with the same key
- check to see if hook is available
- apply_filters/do_action tag characters limit
- Insert term when page is published – avoid duplicates after edits
- How to modify core when there is no hook?
- When does a function assigned to the content_filtered_edit_pre filter hook fire?
- Capture post content before page renders
- Remove_action does not work
- page_attributes_dropdown_pages_args filter does not work
- How to remove action with slashes and arrows?
- Better extend a class or use add filter/action hooks?
- Add content as soon starts
- Make an array filterable per hook
- Changing WordPress core without hacking core
- Comment search plugin
- Plugin options, presets and filters : can you help me improve my workflow?
- how to customize rss feed tags using hooks?
- Woocommerce “added to cart” message on main(home) page
- How to check if a protected hook is hooked?
- Wrapping my head around add_filter
- Gutenberg Block – Post Featured Image Filter Hook
- Admin post list – adding an option to the date filter dropdown
- Modify message displayed on post save
- Change custom post type GUID in RSS
- Pass debug_backtrace() in WordPress filter
- filter hook to load a different post/page on current post/page
- Remove actions/filters that are set with create_function()
- Get The Caller (Plugin / Theme / Core) For All actions & Hook in WordPress
- Redirect to woocommerce checkout after adding to cart – item already in cart
- comment_for() Custom fields not visible when user is logged in
- How to access page variable inside action hook
- I need to hook and change language of facebook sdk
- Use has_filter on comment_post
- How To Get Search Term and Use in Function
- Renaming wordpress login and get new password button
- Is this hook really deprecated? ( manage_{$taxonomy}_custom_column )
- Hook in a sidebar widget and add some markup
- BuddyPress – A hook available to hide custom born date on public profile view?
- Same URL for portfolio and for a page creates 404 error. Is there any filter that i can use for a child page?
- ‘manage_users_custom_column’ is a filter, but ‘manage_posts_custom_column’ is an action. Why?
- How do I add a line break to a string that is output by PHP?
- Scanning for custom embed and prefetching
- The gettext hook doesnt work on text with links
- Filter widget_posts_args not working
- Filter the title to only affect the_title() template function
- Remove and replace woocommerce add to cart button [closed]
- style_loader_tag not changing stylesheet to preload
- How can I filter the comment action links so that I can display the actions links based on user capabilities?
- Hook to change the site URL
- Modify WordPress Page Title ()
- Hook to add content after date in post?
- Is it possible to assign a css id to a row in plugins list table?
- Right filter for rewriting page statuscode
- Add Index to Item in WordPress Gallery
- Re-order search results with posts_orderby filter and post meta value
- How to filter wp_get_recent_posts() to only posts that have thumbnails?
- Adding user filter – Not updating data in URL
- How to check which submission button was clicked?
- Converting restricted html in comments to bbcode
- Why none of xmlrpc filters work
- How to add a class to Buddypress avatars in the Activity stream? [closed]
- Which hook should be used in this case?
- Getting entry ID from frm_email_message filter in formidable
- WooCommerce comments_template Filter Not Firing
- Auto append text after the title?
- str_replace css meta tag?
- How to use apply_filters(‘get_calendar’) to change get_calendar() output?
- Can you call a filter hook by “add_action”?
- Better way to change the default password reset url with the woocommerce one?
- “Invalid parameter(s): attributes” issue in context of “blocks.registerBlockType” filter