仅在页面网址包含/ 200 /
的地方,我需要向header.php添加meta行我们当前正在使用此规则:
<?php if($page == 200) { ?>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="robots" content="noindex, nofollow" />
<?php } ?>
错误日志给出了此补丁的错误:[Tue Mar 12 13:13:15.070693 2019] [:error] [pid 28413] [client 127.0.0.1:29570] PHP注意: 未定义的变量:第页 /nas/content/live/parentsdome1/wp-content/themes/voice/header.php在 第27行
我有一个称为page_number的本地JS参数
我可以以某种方式使用它吗?
关于如何“查询”字符串以查看其是否包含“ / 200 /”的其他想法?
非常感谢!
答案 0 :(得分:2)
您只能使用PHP。
首先get the current URL,然后检查是否it contains a specific string。
<?php
$page = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on'
? "https"
: "http")
. "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
if (strpos($page, '/200/') !== false):
?>
<!-- <meta> -->
<?php
endif;
?>