Support » Fixing WordPress » How to Call a Custom Field in Head?

  • Hi I have a custom field that needs to be called in the head of the page, how could i do this? Because the loop doesn’t occur until after the head i have been unable to find a way to do it?

    Is it possible to Get Post Meta in the head??

    Many Thanks in Advance!

Viewing 8 replies - 1 through 8 (of 8 total)
  • When I need to get the post information in the head, I do something like this:

    <?php if (is_single()) { the_post(); rewind_posts();
    // do whatever
    } ?>

    This will get the post and populate everything, then rewind so that the real Loop later down the page will work correctly. All the loop functions should then work for that one post in the “do whatever” section.

    Thanks Otto this is just what i required. Many Thanks.

    If you happen to read this, i was wondering if you could help me with a problem i’ve had for some time. I’ve searched and posted without reply, Basically i have:

    This works correctly for 1 tag, but how do i search for more than 1 tag, so it displays all posts containing the tag rgrg and all the posts containing another tag? I think i saw a report compiled yourself on a problem with this, and how to solve it but i could not understand it??

    Try something like this:
    'tag_slug__in' => array ('tag1', 'tag2')

    The “in” gets posts with either tag. The “and” only gets posts with both tags.

    Hey Thanks again, I had no luck, i tried:

    'tag_slug__in'=>array('tag 1', 'tag 2'),
    ) );

    This doesn’t display anything at all.


    'tag_slug__and'=>array('tag 1'),
    ) );

    Will display the posts containing tag 1 as mentioned earlier.

    Do you actually have any posts with both tag1 and tag2? The “in” means that the posts pulled must have *BOTH* tags. The “and” means that they can have either tag.

    Also, I don’t think that tag_slug__in will also work with the cat parameter. Try removing that, see what you get.

    There are some incompatibilities between cats and tags in the query. These still need to be worked out, I think even 2.5 has some problems there.

    Oh so it is the “and” that i wanted, to pull posts with EITHER of the tags, it doesn’t have to contain both.

    However the problem still persists. Even if i take the cat parameter out. Here is what i am trying:

    'tag_slug__and'=>array('tag 1','tag 2'),
    ) );?>

    This does not work. But the following does work:

    'tag_slug__and'=>array('tag 1'),
    ) );?>

    Hmmm.. Try it with tag__and and tag__in instead. I may have my in’s and and’s confused. Also, the tag_slug__whatever bits are looking solely at the slugs, not necessarily the term_id’s.

    That whole chunk of code in the query needs to be rewritten to make more sense, IMO. 🙂

    OK many thanks, we have progress tag_slug__in works, however only without the CAT parameter.
    I could probably overcome this by just using certain tags as a flag for a certain category.

    What do you suggest when you say it needs to be rewritten I am open to anything!!

    Also if i add showposts=5 to this query, and only 3 posts match the critera is it possible to have another 2 random posts show up??

    Again Otto i really appreciate your help!!

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘How to Call a Custom Field in Head?’ is closed to new replies.