php - Wordpress: how to start an add_filter inside Class -
sorry no-clear title.
i'm developing plugin , want add custom posts other columns (trying follow tutorial: https://ryanbenhase.com/how-to-add-custom-columns-to-the-all-posts-screen-or-your-custom-post-type-in-wordpress/ ).
in admin class have in __construct()
public function __construct() { $this->perform_filter_hooked_action(); } /** * perform hooks filters * * @since 1.4 */ private function perform_filter_hooked_action() { echo 'perform_filter_hooked_action called'; add_filter('manage_custom_posts_columns' , array ( $this , 'add_columns_to_summary_custom_post')); } /** * * filter add columns summary custom post. * * callback perform_filter_hooked_action * * @since 1.4 */ public function add_columns_to_summary_custom_post( $columns ) { echo 'add_columns_to_summary_custom_post called'; } i on screen first echo (perform_filter_hooked_action called) not second 1 (that other on "add_columns_to_summary_custom_post called").
where wrong?
thank much
when use filters, need return value not echo it. maybe causing issue.
from documentation add_filter() function:
when filter later applied, each bound callback run in order of priority, , given opportunity modify value returning new value.
Comments
Post a Comment