DjordjeB Posted January 23, 2015 Share Posted January 23, 2015 include "header.php"; if(isset($_GET['post_id'])) { $select=mysqli_query($con,"select...."); while($data=mysqli_fetch_array($select)) { echo "bla bla bla"; to_head("<title>asd</title><meta itemprop="name" content="asdfasdf">..."); } } include "footer.php"; This is samthing what i want... I have header.php and footer.php and any script ex news.php where how news and read SEO stuff from database and put in HEAD of the document. I tried with jquery like $("head").append(str); and it works but then i read google don't run jquery when vist website. This is done with drupal, wordpress and php-fusion Drupal: https://api.drupal.org/api/drupal/includes%21common.inc/function/drupal_add_html_head/7 php-fusion: https://www.php-fusion.co.uk/forum/viewthread.php?thread_id=30959 so it is possible but i don't know how. Any idea? Quote Link to comment https://forums.phpfreaks.com/topic/294184-script-to-put-seo-stuff-in-head/ Share on other sites More sharing options...
scootstah Posted January 23, 2015 Share Posted January 23, 2015 You need to add the stuff to the document before you output it. In your example, you are outputting the header and then attempting to add stuff to it afterwards....that's not going to work. This sort of thing is easily done using template engines. You could do something hacky like this: <?php function addHeader($elements) { include 'header.php'; }header.php <html> <head> <?php if (!empty($elements)) { foreach($elements as $element) { echo $element; } } ?> </head>usage addHeader(array('<title>asd</title>', '<meta itemprop="name" content="asdfasdf">')); Quote Link to comment https://forums.phpfreaks.com/topic/294184-script-to-put-seo-stuff-in-head/#findComment-1503965 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.