WordPress.org

Ready to get started?Download WordPress

Forums

Custom Post Type UI
[resolved] Taxonomy IDs (7 posts)

  1. myhero
    Member
    Posted 8 months ago #

    Hi,

    How can I see the ID of custom taxonomy 'Actors'?

    (assuming I've created such a custom taxonomy, with taxonomies within Actors)

    If I click on edit and I hover over it, I get "edittax=0" is this the ID?

    Thanks

    http://wordpress.org/plugins/custom-post-type-ui/

  2. Michael Beckwith
    Member
    Plugin Author

    Posted 8 months ago #

    No, the "edittax" $_GET parameter isn't the ID for the taxonomy. I don't actually believe the taxonomies themselves get a numeral ID, I know the terms in the taxonomy do.

  3. myhero
    Member
    Posted 8 months ago #

    Ok, thank you

  4. markomitranic
    Member
    Posted 8 months ago #

    And how can we find out a term ID via the term slug? I am not able to do that for some time now. Thanks. :)

    $catID2 = get_term_by('macola_raid-2');
    $catID2 = $catID2->term_id;

    This is what i tried last after hours of searching, and it doesn't work.

  5. markomitranic
    Member
    Posted 8 months ago #

    Well, i guess i should have also added this. This is what i would use it for:
    For some reason, i really want the category slug to be forwarded via $_GET to the search code below. The code works if i define the ID myself (for testing purposes), but i need a way to extract the id from the slug that was forwarded :)

    $args = array('post_type'=> array( 'pro_artikl' ), $catID2, 'posts_per_page' => -1);

    I guess something is wrong with the line
    $catID2 = $catID2->term_id;
    because it returns nothing when echoed. Normal categories for example return their id with no problems after that line.

  6. markomitranic
    Member
    Posted 8 months ago #

    Hmm, my error. The $args line actually does not separate the "not searched IDs" as it should. i will open a new support topic for that.

    Can you please answer the ->ID question here anyway? :)

  7. Michael Beckwith
    Member
    Plugin Author

    Posted 8 months ago #

    You aren't passing in all of the right parameters to get_term_by(). It has 3 required.

    1. $field aka either 'slug', 'name', or 'id'
    2. $term aka the value you're wanting to search by
    3. $taxonomy aka category, post_tag, link_category or something custom

    You'll want to do

    $catID2 = get_term_by('name', 'macola_raid-2', 'FILL TAXONOMY HERE' );

    Just replace the "FILL TAXONOMY HERE" part with your actual taxonomy, I'm not sure what that is in your case. That should make it work and return something.

    http://codex.wordpress.org/Function_Reference/get_term_by

Reply

You must log in to post.

About this Plugin

About this Topic

Tags

No tags yet.