WordPress.org

Ready to get started?Download WordPress

Forums

Should get_header be inside The Loop by default? (4 posts)

  1. dpdnolan
    Member
    Posted 9 years ago #

    http://wordpress.org/support/topic/30735

    It does strike me as odd that The Loop is not initialised before get_header() is called. For example, it must be a common requirement to want to add custom <meta> tags in the header based on custom fields on the post/page.

    Any comments?

    (Apologies if this has been covered before. It's hard to search for this topic.)

  2. skippy
    Member
    Posted 9 years ago #

    No, not many folks put meta tags in the header. I think dougal wrote a plugin to do that, though.

  3. dpdnolan
    Member
    Posted 9 years ago #

    Is that cos they don't want to or cos it's too hard? :)

    Dougal's plugin is here: http://dougal.gunters.org/blog/2004/06/17/my-first-wordpress-plugin-headmeta I don't believe it works for WordPress 1.5+ though - not that I'm complaing Dougal!

  4. Ryan Boren
    WordPress Dev
    Posted 9 years ago #

    The Loop is just an interface on top of the global $wp_query object, which is created before templates are loaded. If a query resolves to a single post, page, category, or author, the object for that single entity can be obtained with $wp_query->get_queried_object(). For a single post query, this will return the equivalent of $post. Or, you can use $wp_query->post.

Topic Closed

This topic has been closed to new replies.

About this Topic