Ok so i have a head.php file that i am including to some of my pages that have the same heads. However i am at a loss on how to get page specific things like the title tag, facebook's open graph, and other things required for SEO, inside the head without writing it all out. Is there a variable for that?
There's a few ways you can do this, either by breaking up your head.php into, for example, doctype.php (where you put, doctype and meta charset etc). Then call that on your page.
Then have your title tags on each page.
Then have head.php full of the stuff after that.
Alternatively, what I do is pass a variable, usually to the body class, but it will work in the case of title tags too.
For example, when you call your file at the top of each file/page, create a line above with a variable.
For example:
<?php $pageTitle = "Page Title Goes Here";?>
Then in your head.php have;
<?php echo $pageTitle;?>
It will grab the variable from the document and then echo it out inside your title.
I also do this for body classes (if needed) where I do;
<?php if (empty($bodyclass)) {echo 'DEFAULT_CLASS_GOES_HERE';} elseif (!empty($bodyclass)) {echo $bodyclass;}?>
The above basically sets the default body class if there isn't one passed through, but if there is, it echo's it out.
Ok so i have a head.php file that i am including to some of my pages that have the same heads. However i am at a loss on how to get page specific things like the title tag, facebook's open graph, and other things required for SEO, inside the head without writing it all out. Is there a variable for that?
Cheers
There's a few ways you can do this, either by breaking up your head.php into, for example, doctype.php (where you put, doctype and meta charset etc). Then call that on your page. Then have your title tags on each page.
Then have head.php full of the stuff after that.
Alternatively, what I do is pass a variable, usually to the body class, but it will work in the case of title tags too.
For example, when you call your file at the top of each file/page, create a line above with a variable.
For example:
Then in your head.php have;
It will grab the variable from the document and then echo it out inside your title.
I also do this for body classes (if needed) where I do;
The above basically sets the default body class if there isn't one passed through, but if there is, it echo's it out.
There's a variable for anything,
as long as you assign a variable to it : )
for example
@andy_unleash @traq Thanks guys!