• 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!

Viewing 6 replies - 1 through 6 (of 6 total)
  • 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.

    Thread Starter Anonymous

    Fantastic – thankyou.

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

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

    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); ?>

    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

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Current category or post id’ is closed to new replies.