If you are a developer, in some cases you need to get all categories and their IDs. You might start referring to wordpress codex but most likely you will end up with no solution, just like me. Rather than counting on wordpress’s built-in function, you can write your own MySQL query to accomplish this.
';
}
?>
$table_prefix is a variable declared in wp-config.php, it carries value “wp_” by default unless you changed the setting. It is your SQL tables’ prefix.
WordPress stores all category, tags, etc in wp_term_taxonomy table so we can load all categories name and ID from there.
';
}
?>
WordPress stores all pages in wp_posts table, but with post_type set as “page”.
Hope this helps.
Awesome code! Just an FYI, if you’re using this in a function (like I am), you need to have “global $table_prefix;” (no quotes) prior to the line that starts “$result = mysql_query(“.
Hi, I’ve been looking for a solution in google… but nothing. It was really hard to get this piece of code. Thanks !