Support Forum

Increasing Open Graph Description Length

EK Edward Koon
Edward Koon
Member

G’mornin Everyone.. Happy Holiday.. cool

I’m looking to increase the open graph description output in my forum.

Looks like SimplePress open graph is internally set the same as the meta description length 120 characters or so. It’s said Facebook renders around 300 characters, but longer is OK as it will be truncated. 

Is this controlled by a file i can edit?

Thanks, Ed

15 Answers

New Answer

YS Yellow Swordfish
Yellow Swordfish
Member

There isn’t any length restriction imposed that I am aware of on the meta description….? Indeed ours is about 300 characters. Or am I confusing this for something else?

EK Edward Koon
Edward Koon
Member

Under SEO there is an option to use the first 120 characters for the topic meta description.

Remembering the open graph (og) inclusion came later. It looks like that 120 characters is duplicated for the og description tag.

These days I’m finding out that og description is too short, especially when sharing to Facebook or Google plus. I’m hoping to bump it up to around 300 characters. The meta description could be safely increased to 160 characters for the best seo.

MP Mr Papa
Mr Papa
Member

This does seem to be the case if you are using the excerpt option…  I guess the 120 was a typical, albeit arbitrary, size of an excerpt…  

if you like, you can use the ‘sph_meta_description’ to adjust the meta description as you see fit…  but if you want more chars, you will essentially have to regenerate it…  something like:

global $spVars; global $spVars; 
$content = spdb_table(SFPOSTS, "topic_id={$spVars['topicid']}", 'post_content', 'post_id ASC', 1); 
$description = wp_html_excerpt($content, 120);

but of course change the 120 to what you want…  hook into the filter above, and then add the code above and return $description…

better than changing core code…

EK Edward Koon
Edward Koon
Member

Thanks for that info, Steve.

What sp file would that be in?

Preferably only change the open graph description length.

YS Yellow Swordfish
Yellow Swordfish
Member

if you mean where is it best to put the code then the best way is to create a new file in the wp-content folder named ‘sp-user-functions.php’ and use that. This file will never be touched by any upgrades.

EK Edward Koon
Edward Koon
Member

Created the file and put it in the wp-content directory. Something was echoed to the top of the screen, and the length did not increase. Would i have to uncheck the 120 characters in the seo component settings?

Is there a core file i can edit to increase the characters?

Thanks.. confused

MP Mr Papa
Mr Papa
Member

not sure I follow…  you did something like this??

add_filter('sph_meta_description', 'my_meta_description'); 
function sph_meta_description($description) { 
global $spVars; 
$content = spdb_table(SFPOSTS, "topic_id={$spVars['topicid']}", 'post_content', 'post_id ASC', 1);
$description = wp_html_excerpt($content, 300); 
return $description; 
}

shouldnt echo anything…  search for the $description line in the core files and you will find it…

YS Yellow Swordfish
Yellow Swordfish
Member

Did you wrap the code in php tags. If you didn’t then that could echo…

EK Edward Koon
Edward Koon
Member

Ahhhh.. Wrapped it but no change in the description length. You say core files? Not sure what those would be? Browsed around in a few with a text editor find function but couldn’t find $description

YS Yellow Swordfish
Yellow Swordfish
Member

I have not looked at the code @mr-papa suggested as yet but – while I feel changing core files is not a good idea you can at least test things and do temp live changes with safety.

As far as I know the code is in the file /sp-startup/forum/sp-forum-support-functions.php and the function is sp_get_metadescription() which starts at line 499. You will see the ‘120’ at line 534.

MP Mr Papa
Mr Papa
Member

What was the final code of mine you used???  did it have 120 or 300 (as I suggested you change) in there?

EK Edward Koon
Edward Koon
Member

I have not dug into it today. If the description and open graph description share the same characters I’ll have to fiddle with the length and run I post through Google testing tool checking for overage errors.

On Jul 6, 2017 11:10 PM, “Simple:Press Support” wrote:

MP Mr Papa
Mr Papa
Member

yes, the two share the same length number…  changing the location or using my code will change both as well..

if you want to change just the OG, you would have to go down around line 796 in that same file and not use the meta description…  so you could take the  meat of my code and replace line 796 with it to directly create a separate OG description…

EK Edward Koon
Edward Koon
Member

Hi Steve, not comfortable digging around in php, i increased the number of characters in sp default file. That’s working for now. Thanks for your help as always. wink

The correct length is sketchy. Yoast is saying 160 characters, and does not mention the open graph description. However Search Engine Journal has more in depth info. 

Title tags have been increased to 70–71 characters, which is up from its previous 50–60 characters. That’s at least enough to fit in another word or two.

Meta descriptions have been increased by 100 characters per line, and extended from two to three lines. That’s a significant increase, and presents far more of an opportunity to tell searchers what the page is about.

Slegg reports that Google is still truncating the descriptions to two lines for many search results still, so you may still see them coming in at around 160 characters at times. When a three line snipped is displayed they come in at 278 characters per line.

I’m thinking having separate meta description and open graph description tags would be good idea. An easy core update for y’all. Possibly adding a variable to the SEO component allowing the admin to choose the lengths?