WordPress.org

Forums

Current category or post id (7 posts)

  1. Anonymous
    Unregistered
    Posted 11 years ago #

    I'm working on a hack that creates meta content automatically based on your existing content. I'm having difficulty knowing when a specific category or post is selected. Is there a function or variable I can call to tell me this globally? If not, is there a work around?
    Thanks!

  2. Hella
    Member
    Posted 11 years ago #

    I believe the variable $p in index.php will let you know the ID of the post currently being requested. I'm sure you could then feed that to a function to get the category.

  3. Anonymous
    Unregistered
    Posted 11 years ago #

    Fantastic - thankyou.

  4. codergurl
    Member
    Posted 11 years ago #

    the_ID() & the_category_ID()
    They have to be in the post loop though.

  5. WillM
    Member
    Posted 11 years ago #

    the_category_ID is obsolete I believe. Hasn't worked since multiple cats were introduced.

  6. pIng
    Member
    Posted 11 years ago #

    Instead of using complex hack code, I chose to simply search the query string for the category number, then I've inserted it inline where needed. I'm no PHP guy, but this works great for me and it's one line of code:
    <?php echo($cat); ?>

  7. davidchait
    Member
    Posted 11 years ago #

    wp-blog-header, at the top, has an array of all the fields it looks for in the URL or post-header to select documents to show.
    -d
    http://www.chait.net

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.