douqi3913 2017-01-26 12:58
浏览 21

Widgets_init中的奇怪的WordPress错误在运行带参数的新WP_Query时进行过滤

When using TwentySeventeen theme, if you have a function with a simple new WP_Query with any argument like this in the functions.php:

function wp123_qry_in_widgets_init() {
    $test_qry = new WP_Query( array( 'posts_per_page' => 3 ) );
    if ( $test_qry->have_posts() ) : 
        while ( $test_qry->have_posts() ) : 
            $test_qry->the_post();
        endwhile;
         wp_reset_postdata();
    endif;
}  

And then hook it on to the widgets_init action with:

add_action( 'widgets_init', 'wp123_qry_in_widgets_init' );

Something weird happens when you go to Media -> Add new. When you upload a new image now, the image goes into a seemingly random upload date folder.

For instance, I did it just now and new images are uploaded to 2016/11. Without that function added, the images are uploaded normally to 2017/01.

Why is this unexpected behavior happening?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 HLs设计手写数字识别程序编译通不过
    • ¥15 Stata外部命令安装问题求帮助!
    • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
    • ¥15 TYPCE母转母,插入认方向
    • ¥15 如何用python向钉钉机器人发送可以放大的图片?
    • ¥15 matlab(相关搜索:紧聚焦)
    • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
    • ¥15 Arduino无法同时连接多个hx711模块,如何解决?
    • ¥50 需求一个up主付费课程
    • ¥20 模型在y分布之外的数据上预测能力不好如何解决