Random metatag

2

We use OpenGraph meta tags to further detail our Facebook site for example.

<head>
<meta property="og:locale" content="pt_BR">

<meta property="og:url" content="site.com/blablabla">

<meta property="og:title" content="Título">
<meta property="og:site_name" content="Nome">

<meta property="og:description" content="Descrição">

<meta property="og:image" content="site.com/img.jpg">
<meta property="og:image:type" content="image/jpeg">
<meta property="og:image:width" content="800">
<meta property="og:image:height" content="600">

<meta property="og:type" content="website">

</head>

How do I leave the values between the quotation marks (eg "Name", "Description") with different values for each refresh and that the "Title" is part of the url typed, for example: site.com/ username, and so the og: site: title is "username", is it possible?

    
asked by anonymous 26.10.2017 / 17:00

1 answer

2

If you want to fetch the url from the site, I recommend using $_SERVER['PHP_SELF'] , it will fetch the name of the site and will present it.

You can call it that, <meta property="og:title" content="<?=$_SERVER['PHP_SELF']; ?>"> .

For a better presentation, I recommend replacing any _ or - with empty spaces for better presentation using str_replace() , so the code would be:

$site_url = $_SERVER['PHP_SELF'];
$site = str_replace("_"," ",$site_url);

And in OpenGraph put:

<meta property="og:title" content="<?=$site; ?>">
    
26.10.2017 / 17:23