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.
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.
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.
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? 🙂
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.ww.wp.xz.cn/Function_Reference/get_term_by