簡體   English   中英

如何動態更改頁面的og:title

[英]How can I dynamically change the og:title of my page

本質上,我有一個網站,該網站使用查詢字符串根據用戶輸入的網址動態更改內容。 我還使用.htaccess文件重寫了網址以刪除問號,因此它看起來就像是另一個頁面。 例:

www.site.com/233 - loads content associated with the ID 233

我的問題是,當某人喜歡facebook上的頁面時,盡管我使用JS將like的url更改為當前頁面,但無法看到(在當前編碼能力范圍內)動態更改og:url og:title等,帶有查詢字符串。

我想要的結果是,當某人喜歡我的頁面時,它會在新聞訂閱源上顯示用戶喜歡的內容。

user liked www.site.com/231 - instead of it showing just 'site' in the newsfeed
I wish it to show the extention, i.e 'site - content 231' for /231 and 'site -
content 4234' for /4234

目前,我不得不設置一個基本的og:title,而沒有設置og:url,因為顯然對於查詢字符串的每個擴展它都是相同的。

我的評論的簡單解釋:

// router.php

// process URL and blah blah blah here

$config = array(
     "og" => array(
         "title" => "Cool Page"
     )
);
include 'template.php';


// template.php
<html>
    <head>
        <title><?php echo $config["og"]["title"]; ?></title>
    </head>
    <body>
    </body>
</html>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM