Metatag aleatoria

Asked

Viewed 35 times

1

We use the metatags of Opengraph to detail a little more our site on Facebook 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>

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

  • Ever tried to use <meta property="og:url" content="<?= $site; ?>"> ?

1 answer

1


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

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

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

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

And in Opengraph put:

<meta property="og:title" content="<?=$site; ?>">

Browser other questions tagged

You are not signed in. Login or sign up in order to post.