I've just started learning Wordpress and going through standard/default themes. If i have understood filters idea correctly, before we can apply them we need to add callback functions via add_filter($hook, $callback, $args)
. However looking at the 'twentyseventeen' theme i can't see those declaration for twentyseventeen_starter_content
and it is used then with: $starter_content = apply_filters( 'twentyseventeen_starter_content', $starter_content );
(file functions.php) and twentyseventeen_front_page_sections
- $num_sections = apply_filters( 'twentyseventeen_front_page_sections', 4 );
(file front-page.php). What am i missing and how does it work without setting callback functions?
Wordpress'二十七'主题过滤声明
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
1条回答 默认 最新
- dongtangjie0495 2018-03-25 19:07关注
apply_filters
runs all the callbacks attached to it byadd_filter
to the same hook/tag. If there are no callbacks attached to that hook/tag it returns the second parameter (which is the value beng filtered) of theapply_filters
. Thereforeapply_filters( 'twentyseventeen_front_page_sections', 4 );
will return 4 if there are noadd_filter('twentyseventeen_front_page_sections', 'callbackfunc');
. Else it will return the result of the add_filter callback with the highest priority after going through all callbacks.Priorities are set in the
add_filter
as the third parameter.I don't know if this what you were looking for but i thought it might give you a better understanding.
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报
悬赏问题
- ¥15 有偿求码,CNN+LSTM实现单通道脑电信号EEG的睡眠分期评估
- ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
- ¥50 成都蓉城足球俱乐部小程序抢票
- ¥15 yolov7训练自己的数据集
- ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
- ¥15 电力市场出清matlab yalmip kkt 双层优化问题
- ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)
- ¥20 matlab yalmip kkt 双层优化问题
- ¥15 如何在3D高斯飞溅的渲染的场景中获得一个可控的旋转物体
- ¥88 实在没有想法,需要个思路