1 (edited by kacper3100 2018-11-02 08:22:32)

Topic: How to add tags Open Graph in between <head> tags?

I would like the title of the article to appear in the og: title tag, and the content fragment in the og: description tag. How to do it?

Re: How to add tags Open Graph in between <head> tags?

To do this, use some of the built-in API CuteNews tools. At first, add the strings below to the very beginning of the file, which contains the code <head>,

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

Then, you can use such strings as
if ($entry) {
       echo '<meta property="og:title" content="'.htmlspecialchars($entry['t']).'" />';
       echo '<meta property="og:description" content="'.htmlspecialchars(substr($entry['s'], 0, 100)).'" />';
   }

Best regards,
CN Support team

3 (edited by kacper3100 2018-11-12 16:21:32)

Re: How to add tags Open Graph in between <head> tags?

Thanks.

How to do it for photos?

Re: How to add tags Open Graph in between <head> tags?

Could you, please, specify the photo source? Will the photo be inserted into the additional field or wil it be extracted from the text?

In the first case, you just need to use $entry['mf']['the additional field name'], for example

echo '<meta property="og:image" content="'.htmlspecialchars($entry['mf']['myimage']).'" />';

myimage is the field name here.

Best regards,
CN Support team

5 (edited by kacper3100 2018-11-13 19:13:53)

Re: How to add tags Open Graph in between <head> tags?

I add photos to the server on which I have a website, then I add a link to the photo in the article.

Re: How to add tags Open Graph in between <head> tags?

To do this, you should use additional fields to insert a photo there.

To add a new field, go to Dashboard> Additional fields, select the type 'Image / Resource', the og_image name, for example. Then click 'Add / Replace field'.

When editing the news, a new og_image field will appear, with which you can select an image for the article. Then, as in the previous case, you can add this string to the <head> section
if (! empty ($ entry ['mf'] ['og_image']))) echo '<meta property = "og: image" content = "'. $ entry ['mf'] ['og_image']. '" /> ';

Best regards,
CN Support team

7 (edited by Janice916 2018-12-25 04:14:06)

Re: How to add tags Open Graph in between <head> tags?

Open Graph meta tags should always be nested between <head> tags.

To turn your web pages into graph objects, you need to add basic metadata to your page. We've based the initial version of the protocol on RDFa which means that you'll place additional <meta> tags in the  <head> of your web page.

8 (edited by kacper3100 2018-11-17 11:52:41)

Re: How to add tags Open Graph in between <head> tags?

Support_Team wrote:

To do this, you should use additional fields to insert a photo there.

To add a new field, go to Dashboard> Additional fields, select the type 'Image / Resource', the og_image name, for example. Then click 'Add / Replace field'.

When editing the news, a new og_image field will appear, with which you can select an image for the article. Then, as in the previous case, you can add this string to the <head> section
if (! empty ($ entry ['mf'] ['og_image']))) echo '<meta property = "og: image" content = "'. $ entry ['mf'] ['og_image']. '" /> ';

This don't work. "Parse error: syntax error, unexpected 'entry' (T_STRING), expecting variable (T_VARIABLE) or '$' in /usr/home/news.php on line 15"

Did I paste well?

http://i67.tinypic.com/sb58gy.png

Re: How to add tags Open Graph in between <head> tags?

Please use this code string:
if (!empty($entry['mf']['og_image'])) echo '<meta property="og:image" content="'.$entry['mf']['og_image'].'" />';

Best regards,
CN Support team

Re: How to add tags Open Graph in between <head> tags?

Thanks a lot, it works.

Re: How to add tags Open Graph in between <head> tags?

Adding Open Graph to web pages This involves adding tags within the section of the page HTML code. Syntax This tag allows the use of two attributes which include property and content. TellCulvers.com