KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I am trying to add dynamic Facebook og meta tags to my Wordpress site. I am adding them to single.php instead of the usually recommended functions.php file because I have code below that for a Facebook app I've created that needs to execute every time someone views an individual blog post because it then posts to their Facebook timeline that they've read that particular post. I don't want to use a plugin because some of my plugins used to conflict with each other and it was a mess to get that straightened out. My biggest problem is that I need the og:url tag to be dynamic, though the og:title , og:description , og:image , etc. should be as well. Here is the code I have at the top of my single.php file: EDIT: HERE IS THE WORKING CODE I AM NOW USING. THANKS FOR EVERYONE'S HELP: <?php $params = array(); if(count($_GET) > 0) { $params = $_GET; } else { $params = $_POST; } // defaults if($params['type'] == "") $params['type'] = "picture"; if($params['locale'] == "") $params['locale'] = "en_US"; if($params['description'] == "") $params['description'] = "Visit Internet LOLs for the funniest humor on the web! :)"; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> <head prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb# internetlolsapp: http://ogp.me/ns/fb/internetlolsapp#"> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <!-- Open Graph meta tags --> <meta property="fb:app_id" content="378076268920252" /> <meta property="og:site_name" content="meta site name"/> <meta property="og:url" content="<?php echo 'http://internetlols.com'.$_SERVER['REQUEST_URI']; ?>"/> <me
Tags (comma-separated)
Save Edits
Cancel