Jump to content

Recommended Posts

This will add the meta data for sharing Knowledgebase articles on Facebook and Twitter.


It gets the article title, description and it selects the first image from the article if any to show on your social share post.


I have separate meta data sections for different pages, this is just the knowledgebase section.


Change the "yourdata" accordingly. Adjust as needed.


 <title>{if $catname}{$catname}{/if} - {if $kbarticle.title}{$kbarticle.title} - {/if}{$pagetitle} - {$companyname}</title>
   <meta name="description" content="{$kbarticle.text|truncate:150|strip_tags}">

{if preg_match('/< *img[^>]*src *= *["\']?([^"\']*)/i',$kbarticle.text, $result)}

<meta property="og:image"
content="{$result[1]}" />
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:image" content="{$result[1]}">
<meta property="og:title" content="{if $catname}{$catname} -{/if} {if $kbarticle.title}{$kbarticle.title} - {/if}{$pagetitle} - {$companyname}" />
<meta property="og:site_name" content="yourdata"/>
<meta property="og:url" content="http://{$smarty.server.HTTP_HOST}{$smarty.server.REQUEST_URI}" />
<meta property="og:description" content="{$kbarticle.text|truncate:150|strip_tags:false}" />
<meta property="fb:app_id" content="yourdata" />

<meta name="twitter:site" content="@yourdata">
<meta name="twitter:creator" content="@yourdata">
<meta name="twitter:title" content="{if $catname}{$catname} -{/if} {if $kbarticle.title}{$kbarticle.title} - {/if}{$pagetitle} - {$companyname}">
<meta name="twitter:description" content="{$kbarticle.text|truncate:150|strip_tags:false}">

  • Like 1

Share this post

Link to post
Share on other sites

This is great, thanks! Where did you add this and does it still work?

Also, is there similar code for "Announcements"?

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Similar Content

    • By Inetbiz
      Product or service emails... I'm wondering what would be the best way to garner a request for the user to +1 subscribe to the G+ business page?
    • By nimonogi
      Take advantage of the following
      WHMCS Addons FREE of charge for 48 hours! 
      Offer is available to new and existing customers.
      The Coupon Code is: 100%FREE


      Supports WHMCS v5 & v6
      For Screenshots and More Details visit our WHMCS Addons page.

  • Recently Browsing   0 members

    No registered users viewing this page.


Important Information

By using this site, you agree to our Terms of Use & Guidelines