How to elect position of new item output in a dropdown when using add_filter

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 … Read more

Why isn’t this add_filter function working as expected?

apply_filters( $tag, $value, $param, $otherparam ) This is how the apply_filters function work. By default, the value is printed if no function is hooked with the filter. It’s not clear what directorist_icon( ‘fas fa-chevron-right’, false ) prints here. But if it is showing “next” string at the output, the filter is working right. If you … Read more

Can you call a filter hook by “add_action”?

add_action() and add_filter() are the same function. If you look at the source you’ll see that add_action() just calls add_filter(). So yes, this it is technically possible to register a filter callback with add_action(). The difference between an action and a filter is that filters expect a return value, while actions do not. This is … Read more