WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] How fetch category ID? (5 posts)

  1. Thord Daniel Hedengren
    Member
    Posted 7 years ago #

    I'm trying to fetch the category ID for a post, in the same way as <?php the_ID(); ?> does, to be included in a html tag. Is this possible?

    Thanks in advance!

  2. ZMAng
    Member
    Posted 7 years ago #

    See this WP Codex article. I do hope your posts only have one category though since when multiple categories come in, I'd say your job is going to involve substantial irritation.

  3. Thord Daniel Hedengren
    Member
    Posted 7 years ago #

    I looked at that one but it's marked as deprecated which make me doubt using it. And yes, just one category at a time. :)

  4. ZMAng
    Member
    Posted 7 years ago #

    Check the part at the bottom, where they talk about what has replaced it.

  5. Thord Daniel Hedengren
    Member
    Posted 7 years ago #

    Aw, I'm blind...! I totally missed that part. Worked like charm. Thanks. :)

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags