weelow Posted June 3, 2020 Share Posted June 3, 2020 Hello, I am trying to find an easy way to change the announcements page title according to the article title, just like knowledge base, and maybe excerpt the data to get a summary for the description for the purpose of SEO. Any ideas? The plugin below, is what i want to achieve. It is no longer available but you can check the screen shots to get an idea. https://marketplace.whmcs.com/product/3887-hook-announcement-and-product-title 0 Quote Link to comment Share on other sites More sharing options...
Kian Posted June 4, 2020 Share Posted June 4, 2020 <?php add_hook('ClientAreaHeadOutput', 1, function($vars) { if ($vars['templatefile'] == 'viewannouncement') { return <<<HTML <meta name="description" content="{$vars['summary']}"> HTML; } }); add_hook('ClientAreaPageAnnouncements', 1, function($vars) { return array('pagetitle' => $vars['title']); }); To be honest, there's almost no benefit in doing that due to the following reason: Meta descriptions are not a ranking factor Google "sees" WHMCS in default language only Good meta descriptions can't be simply an excerpt 1 Quote Link to comment Share on other sites More sharing options...
weelow Posted June 4, 2020 Author Share Posted June 4, 2020 I dumped the $vars to attempt to find the right one but I didnt spot this one. I will trying applying it and tell you how it goes. The reason I want to do that is for sharing the article on social media or whatsapp I want to be able to add the default og:image and og:title and so on. Later on a module can be developed that adds feature to the announcement for SEO title and description. But I needed the right $vars to pull the article ID or anything useful to perform additional ditect database query or add a new seo table and relate them. But for the time being have a proper title and an image will suffice for social media sharing. Thanks Kian. 0 Quote Link to comment Share on other sites More sharing options...
Kian Posted June 4, 2020 Share Posted June 4, 2020 (edited) So you need to implement Open Graph Protocol and not just Meta Description tag. In fact not all platforms use Meta Description when posting links. For example if I remember correctly, Facebook doesn't care or Meta Description, it looks for OG metas. Edited June 4, 2020 by Kian 0 Quote Link to comment Share on other sites More sharing options...
weelow Posted June 4, 2020 Author Share Posted June 4, 2020 (edited) That is exactly what I have in mind. It is really not useful to have this kind of announcement system when all announcements on what'sapp have the same title. Announcement-company. 😅. I just want to make it more useful. Edited June 4, 2020 by weelow Adding reason 0 Quote Link to comment Share on other sites More sharing options...
Jason Levine Posted June 6, 2022 Share Posted June 6, 2022 On 6/4/2020 at 5:35 AM, Kian said: <?php add_hook('ClientAreaHeadOutput', 1, function($vars) { if ($vars['templatefile'] == 'viewannouncement') { return <<<HTML <meta name="description" content="{$vars['summary']}"> HTML; } }); add_hook('ClientAreaPageAnnouncements', 1, function($vars) { return array('pagetitle' => $vars['title']); }); To be honest, there's almost no benefit in doing that due to the following reason: Meta descriptions are not a ranking factor Google "sees" WHMCS in default language only Good meta descriptions can't be simply an excerpt How can this same hook be repurposed for use on ALL pages? 0 Quote Link to comment Share on other sites More sharing options...
vinod makwana Posted May 18, 2023 Share Posted May 18, 2023 <?php add_hook('ClientAreaHeadOutput', 1, function($vars) { $uri_path = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH); $uri_segments = explode('/', $uri_path); $articleArr = array( 1 => 'knowledgebase meta', ); $annouArr = array( 1 => "announcements meta", ); $returnStr=''; if ( array_key_exists($vars['kbarticle']['id'], $articleArr) ) { $meta = '<meta name="description" content="'.$articleArr[$vars['kbarticle']['id']].'">'; }elseif($uri_segments[2] == 'announcements' && array_key_exists($vars['id'], $annouArr)){ $meta = '<meta name="description" content="'.$annouArr[$vars['id']].'">'; }else{ $meta = ''; } if (isset($meta) && !empty($meta)) { $returnStr .= $meta; } return $returnStr; }); similar you can add title. 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.