• Hi,
    I was wondering if it better(for performance) to put noindex, follow and meta descriptions in a child theme’s head.php or the child theme’s functions.php. I know when placed in the functions I will not have problems in case of theme updates, but what is better for performance?
    Thanks.

Viewing 4 replies - 1 through 4 (of 4 total)
  • I, personally, keep as much separated from the theme as I can, this allows me as a dev to edit what I need to without having to worry about a designer stepping on my toes.

    Plus, by putting it in functions.php you allow future devs to override it should they feel the need to do so.

    Honestly unless you’re doing a crazy loop of some kind to generate the content in the head, you will not see a huge performance change/gain rather than using it in functions.php

    Thread Starter danina84

    (@danina84)

    I am mostly thinking about adding meta tags into header vs putting them into a function.

    Moderator bcworkz

    (@bcworkz)

    Like Jerry said, no noticeable difference in performance. If the meta tags somehow had to do with how the site appears visually, i.e. “theme stuff”, then the header template would be reasonable. Otherwise make it a function, preferably with a hook for others to be able to easily alter how the function works.

    If it really has nothing at all to do with a theme, I personally would put the function in a plugin. All my sites have a site specific plugin for such random code so the theme can be easily changed without having to fuss with child themes.

    I personally would put the function in…a site-specific plugin for such random code…

    Yes, and maybe have a look at ‘Code Snippets’:

    https://wordpress.org/plugins/search.php?q=code+snippets

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

The topic ‘Placing in head vs functions.php’ is closed to new replies.