Querying a post's info in multiple locations within a page? (3 posts)

  1. amory
    Posted 10 years ago #

    I am attempting to setup the (single post) page with the title and content in the main content <div> and have the custom fields, category, date etc.. display just to the right in the sidebar. I could manaully code this in, but it would disrupt the commentform as located before it are the endif and endwhile calls to end the loop.

    Thus, is there a way in which I can resetup the postmeta(?) data for use in another location outside the loop in such a way that it could be setup to automatically retrieve the data per whichever post the user may be viewing?

    Actually, wouldn't it work to just store the category to a variable like $temp_category and call that from a different location outside of the loop?

  2. davidchait
    Posted 10 years ago #

    so long as it's a single post, it USED to be the case that you could still call those functions after The Loop, and they'd still be setup for the one post.

    that MAY have changed in the last release or two. In that case, yes, just build everything into an output variable (like $postmetaout = "In: ".get_the_category();) inside the loop, then just echo that outside whereever you want it.


  3. amory
    Posted 10 years ago #

    Wow...Think I should have tried that before posting, eh? :)

    Thanks for the reference though on the output variable, that will be useful for something else I'm working on.

Topic Closed

This topic has been closed to new replies.

About this Topic