Topic: How to add meta tags in HEAD section of each news?

I need to manually add meta tags in HEAD section in every news I've created.
How to edit meta tags for each news individually?

Re: How to add meta tags in HEAD section of each news?

Hello,

This can be done by inserting a code on the page (at the very top of the php page):

     require_once ("cn_api.php");
     $ entry = cn_api_get_entry ();

And then, somewhere in the code where HEAD is output, for example:

<head>
....
<? If ($ entry) {echo '<meta .... content = "'. $ entry ['tg']. '" />'; }?>
...
</ head>

To output the tags. The way of displaying is given approximately, it will be necessary to correct.

Best regards,
CN Support team

Re: How to add meta tags in HEAD section of each news?

Hello,

Support_Team wrote:

This can be done by inserting a code on the page (at the very top of the php page):

     require_once ("cn_api.php");
     $ entry = cn_api_get_entry ();

Can you precise, where should I insert a code? Which .php file?

Support_Team wrote:

And then, somewhere in the code where HEAD is output (...)

You mean I need to put it to a Full Story with HTML enabled in this article?

Re: How to add meta tags in HEAD section of each news?

Dear Support Team,

can you help?

Re: How to add meta tags in HEAD section of each news?

For example, you have the file index.php

<html>
<head>
     <title>My site</title>
</head>
<body>
     <? include 'cutenews/show_news.php'; $ entry = cn_api_get_entry (); ?>
</body>
</html>

It is necessary to modify the file so that it will be so:

<? require_once ("cn_api.php"); $entry = cn_api_get_entry(); ?>

<html>
<head>
     <title>My site </title>
     <? if ($entry) {echo '<meta name="description" content="'. $entry['tg']. '" />'; }?>
</head>
<body>
     <? include 'cutenews/show_news.php'; ?>
</body>
</html>

Best regards,
CN Support team

6 (edited by Helios 2017-08-07 14:51:56)

Re: How to add meta tags in HEAD section of each news?

Thanks for your help. It's working.

7 (edited by Helios 2017-08-08 11:37:00)

Re: How to add meta tags in HEAD section of each news?

<head>
     <title>My site</title>
     <? if ($entry) {echo '<meta name="description" content="'. $entry['tg']. '" />'; }?>
</head>

Is it possible to modify that code to get unique title as well?
How to change <title>My site</title> to <title>Article title - My site</title>?


-- Edit
I found it. Just replace 'tg' to 't'.

Re: How to add meta tags in HEAD section of each news?

Changed by a similar method

  <? If ($ entry) {echo '<title>'. $ Entry ['t']. '- My Site </ title>'; }?>

Best regards,
CN Support team

Re: How to add meta tags in HEAD section of each news?

MyKFCExperience

Support_Team wrote:

For example, you have the file index.php

<html>
<head>
     <title>My site</title>
</head>
<body>
     <? include 'cutenews/show_news.php'; $ entry = cn_api_get_entry (); ?>
</body>
</html>

It is necessary to modify the file so that it will be so:

<? require_once ("cn_api.php"); $entry = cn_api_get_entry(); ?>

<html>
<head>
     <title>My site </title>
     <? if ($entry) {echo '<meta name="description" content="'. $entry['tg']. '" />'; }?>
</head>
<body>
     <? include 'cutenews/show_news.php'; ?>
</body>
</html>

Many thanks for that complete information!