• # November 18, 2012 at 1:56 pm

    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?


    # November 18, 2012 at 2:18 pm

    This reply has been reported for inappropriate content.

    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.

    # November 18, 2012 at 2:19 pm

    > Is there a variable for that?

    There’s a variable for anything,

    as long as you assign a variable to it : )

    for example

    < ?php
    $title = “My Page Title”;

    $template = < << HTML
    < !doctype html>



    print $template;

    # November 18, 2012 at 8:52 pm

    @andy_unleash @traq Thanks guys!

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.