【问题标题】:WordPress functions.php custom code - I don't see error, but no render of content on frontendWordPress functions.php 自定义代码 - 我没有看到错误,但没有在前端呈现内容
【发布时间】:2022-06-10 23:16:57
【问题描述】:

我真的需要有关此代码的帮助,因为无法弄清楚为什么不工作,甚至没有语法错误,内容根本不会在前端呈现。

我创建了带有问题和答案的测验块。现在我想在一定数量的问题后展示混合类型的广告。示例代码如下:

add_filter('render_block_buzzeditor/personality-question', 'add_question_ad_place', 10, 2);
add_filter('render_block_buzzeditor/trivia-question', 'add_question_ad_place', 10, 2);

$question_count = 1;
function add_question_ad_place($block_content, $block)
{
// only after the 2nd question
if($question_count === 2) {
$block_content .= 'ad code after 2';
}

if($question_count === 4) {
$block_content .= 'ad code after 4';
}

if($question_count === 6) {
$block_content .= 'ad code after 6';
}

$question_count++;

return $block_content;
}​

想法是计算问题块,并在一定数量的块(本例中为 2,4,6)之后放置广告代码,并在第 2、4 和 6 个问题之后有广告。

没有 PHP 错误,只是不会在前端呈现内容。我在这里想念什么?谢谢各位。

【问题讨论】:

  • 在你的函数add_question_ad_place中,放置一个die("here");,看看它是否被调用

标签: php wordpress filter ads


猜你喜欢
  • 2015-04-27
  • 1970-01-01
  • 1970-01-01
  • 2019-03-12
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-05-18
相关资源
最近更新 更多