您好,我不会寻找wordpress插件或其他东西。这是我的php页面。
<html>
<head>
blablablalba
<?php to_head(); ?>
</head>
<body>
bla bla bla
<?php
if(isset($_GET['post_id'])) {
$select=mysqli_query($con,"select....");
while($data=mysqli_fetch_array($select)) {
echo "bla bla bla";
to_head("<title>asd</title><meta itemprop="name" content="Najnovije informacije iz sveta hostinga">...");
}
}
?>
bla bla bla
</body>
</html>
我需要为每个新闻帖子设置不同的元标记并放入头部..我该怎么做?
答案 0 :(得分:0)
你需要填充变量,然后将变量回显到html ... par example
<?php
if(isset($_GET['post_id'])) {
$head = "bla bla";
$body = "bla bla";
$select=mysqli_query($con,"select....");
while($data=mysqli_fetch_array($select)) {
$body .= "bla bla bla";
$head .= "<title>asd</title><meta itemprop="name" content="Najnovije informacije iz sveta hostinga">...";
}
}
?>
<html>
<head>
<?= $head ?>
</head>
<body>
<?= $body ?>
</body>
</html>
答案 1 :(得分:0)
<?php
ob_start();
include("header.php");
//some mysqli_query with $seo='tags...';
//this is body of document
//footer of document footer.php start
?></body>
</html>
<?php
$buffer=ob_get_contents();
ob_end_clean();
$buffer=str_replace("#</head>#",$seo."</head>",$buffer);
echo $buffer;
//end of footer.php
?>
这就是我在php中寻找的东西,从查询到头部设置元标记 这可以消耗掉,但是想法就是这样。 tnx evryone回复和评论..