I have a recipe site where I have recipe names in H1 tags on the recipe pages. For SEO reasons I need that recipe keywords in the H1 tag to show up in the meta title and the meta description tag. I am very php challenged and will pay $10 to the one that can lead me through this problem. Its a template driven site/script.
Thanks bordello, a good answer, but that answer belongs to another question I need to copy the text of the H1 tag on one page into the desc and title meta tags on the same page. Anyone?
Ok, where does the text that is in the H1 tags come from? is it hard-coded? what does your template look like? how does the content get put into your template? There are literally a hundred different answers to your question but insufficient info to be able to provide one that will work.
The info in the H1 tag is coming from a data base of recipes. And the title and description meta tags showed on a recipe page are coming from a template page called include.php witch is used in every page on the site.
So all you need to do is check in the code what is the name of the variable or individual array property that gets into the H1 titles, and insert the same variable in your meta description tag.
That is my problem. This is the code that makes the H1: <h1><?php echo $row_recipe["name"];?> - oppskrift</h1> If I put this in the <title><?php echo $site_title; ?></title> in the iclude.php file, the recipe name will not show in the title meta tag.
This is either an old or bad code... anyway... thats probably because include.php doesnt know what $row_recipe["name"], you should check where the $row_recipe query comes from and either include it or copy it into include.php
The php file in question calls include.php in its head. Include.php renders the header (title + meta) for the page. There for the header is rendered before the variable in question has a value (this variable isn't defined until later in the file that calls include.php). I tried placing the contents on incude.php into the header of the file in question so the variable would be defined when it was referenced but this didn't work for unknown reasons. Good luck
Thanks, looks like I need it What do you mean hextraordinary, "This is either an old or bad code." Would it not work if it is an old code?
I included that function after the DB connect but before the include.php functions get ran. Even when the code from include.php is INSIDE the other PHP file and preceded by the function that defines $row_recipe trying to echo the variable fails for the title and meta but still works for the h1. It was something like this file.php _____ include("thumbnail.php"); include("include.php"); ... function that gets $row_recipe ... echo of $row_recipe into h1 ..(other stuff) _____ includes.php _____ connect to db .. make meta .. make title ..(other stuff) _____ So I did it like this new.php _____ include("thumbnail.php"); connect to db function that gets $row_recipe .. make meta + $row_recipe ..(other includes.php stuff).. make title + $row_recipe .. echo of $row_recipe into h1 .. ..(rest of file.php) _____ But when I do this $row_recipe is only echo'd the last time and not the first two times. The first two times it has a null value (?). If I check the source of the output file the meta is like <meta name="description" content=" ">. Where the space in " " should be the same $row_recipe echoed later in the document.
Yes, yes it is. I went through that song and dance about 10 times and always ended up with unexpected results.
Thanks for trying. Damn, I need those H1 keywords in the title and desc. I cannot use the script if I cant do that. Is there a way to rebuild the script then?
Where's the code that your talking about, I can take a look and make it work for you ... damn I love challenges
sounds reasonably easy to sort out - drop ne a copy of your script and I'll see what I can come up with...