Can posts have parents?

Out of the box, no, posts can’t have parents. They can be assigned to categories, which can be organised hierarchically. Pages, however, can have parents and you can build a menu structure out of them by using that feature. As to where this is enforced: The parent of a post is stored in the column … Read more

Checking if Database Table exists

If you use “IF NOT EXISTS” then the dbdelta script will not upgrade your database with delta’s appeared after the initial creation of the database. (assuming you want to re-use the same sql script) at least… that is what i think

How can I trust switch_to_blog()?

@G.M.’s idea to cache the check has lead me to the following helper function. I’ve put it into the global namespace to have it available everywhere. The function doesn’t say anything about the blog status, just if it exists and is not marked as deleted. The database query is very fast (0.0001 seconds) and runs … Read more

get_results using wpdb

global $wpdb; $result = $wpdb->get_results ( ” SELECT * FROM $wpdb->posts WHERE post_type=”page” ” ); foreach ( $result as $page ) { echo $page->ID.'<br/>’; echo $page->post_title.'<br/>’; }

WordPress default menu in database

Menu by itself is a taxonomy in WP. It means that you can find all menus in wp_terms table, by running following query: SELECT * FROM wp_terms AS t LEFT JOIN wp_term_taxonomy AS tt ON tt.term_id = t.term_id WHERE tt.taxonomy = ‘nav_menu’; Menu item is custom post type in WP. They are stored in wp_posts … Read more