自从从PHP 7.4更新到PHP 8以来,我的error_log
现在,我使用的一个儿童主题中充满了这样的行:
【2021 10月17日13:30:38 UTC】PHP警告:尝试读取属性;term\\u id;在bool-in/public\\u html/wp内容/主题/主题名子项/函数。php在线181
这是抛出错误的块。它用于修改分页,以便不导航特定类型(链接)的帖子。
// modify pagination to exclude post_format of \'link\' on news/blog posts
function profound_navigation() {
$previous = ( is_attachment() ) ? get_post( get_post()->post_parent ) : get_adjacent_post( false, \'\', true );
$next = get_adjacent_post( false, \'\', false );
if ( ! $next && ! $previous ) {
return;
}
$link_term = get_term_by(\'slug\' , \'post-format-link\' , \'post_format\');
$quote_term = get_term_by(\'slug\' , \'post-format-quote\' , \'post-format\');
the_post_navigation(
array(
\'next_text\' => \'<span class="meta-nav">Next Article <i class="flaticon-right-arrow"></i></span><h3 class="title">%title</h3>\',
\'prev_text\' => \'<span class="meta-nav"><i class="flaticon-left-arrow-1"></i> Previous Article</span><h3 class="title">%title</h3>\',
// \'taxonomy\' => \'post_format\',
\'excluded_terms\' => array($link_term->term_id, $quote_term->term_id, 156),
)
);
}
代码似乎仍然可以正常工作,但如何修改此代码以避免填写错误日志?