Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP in meta tags not working?
    text
    copied!<p>I'm very new to programming so bear with me... My site is based on Wordpress, so I have an index page that says <code>&lt;?php get_header(); ?&gt;</code> and <code>&lt;?php include('pagecontent.php'); ?&gt;</code>... My header.php contains what you'd expect and pagecontent.php is actually a pretty complex page that grabs several variables from a database (for instance, <code>$result-&gt;properties-&gt;name</code>). I'm starting to integrate Facebook Connect plugins (the like button and comment box), and when I put PHP in my <code>&lt;meta&gt;</code> tags in the <code>&lt;head&gt;</code>, Facebook doesn't recognize the value of <code>$result-&gt;properties-&gt;name</code>... IF my php files were all the same, the relevant code would look like this:<br /></p> <pre><code>&lt;html xmlns="http://www.w3.org/1999/xhtml" xmlns:og="http://ogp.me/ns#" xmlns:fb="https://www.facebook.com/2008/fbml"&gt; &lt;head&gt; [REMOVED THE DIV TAG HERE]&lt;script src="http://connect.facebook.net/en_US/all.js#xfbml=1"&gt;&lt;/script&gt; &lt;?php echo '&lt;meta property="og:title" content="' . $result-&gt;properties-&gt;name . ' on Name of Site"/&gt;'; echo '&lt;meta property="og:type" content="movie"/&gt;'; echo '&lt;meta property="og:image" content="http://ia.media-imdb.com/rock.jpg"/&gt;'; echo '&lt;meta property="og:site_name" content="Name of Site"/&gt;'; echo '&lt;meta property="fb:admins" content="698461078"/&gt;'; echo '&lt;meta property="og:description" content="' . $result-&gt;properties-&gt;description . '"/&gt;'; ?&gt; &lt;/head&gt; &lt;body&gt; [MOVED DIV TAG DOWN HERE]&lt;div id="fb-root"&gt;&lt;/div&gt;&lt;fb:like href="http://www.sitename.net/?sg=' . $sg_id . '&amp;task=0" send="false" layout="button_count" width="450" show_faces="true" action="recommend" font="tahoma"&gt;&lt;/fb:like&gt; &lt;/body&gt; </code></pre> <p>I tried to be as complete as possible to avoid guesswork :P This code gives liked pages the title " on Name of Site" instead of "Name of Movie on Name of Site". Why isn't it able to grab the variable? Is there something I can do to modify the meta tags from within pagecontent.php? Please don't be afraid to state the obvious things! Many thanks ;)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload