PHP Code to Display Term URL & Name of a Post Under a Custom Post Type

Use get_object_taxonomies to get all of the taxonomies registered to a particular post type. Also, don’t use query_posts for secondary queries. or ever, actually. Use WP_Query. $args = array( ‘posts_per_page’ => 1, ‘post_type’ => ‘movies’, ‘orderby’ => ‘post_date’, ‘meta_key’ => ‘featured_movie’, ‘meta_compare’ => ‘=’, ‘meta_value’ => 1, ); $movie = new WP_Query( $args ); if( … Read more

Programmatically add posts add and assign postmeta and assign terms

The woocommerce product category is just a custom taxonomy. As far as I know all the data is stored as intended by wordpress core. You can find out more about the database structure at the codex page Database Description, the tables you are looking for are wp_terms, wp_term_relationships and wp_term_taxonomy. But you absolutely should look … Read more

Hierarchical Taxonomy Terms Select Menu Output with selected=”selected” Set

In each foreach loop, you’re setting the first item’s ID as the value for $selected which will obviously match the ID of the first item. Before running any of the foreach loops fetch the stored value from the DB then use that for the comparison. global $wpdb; $selected = $wpdb->query( “SELECT something FROM $wpdb->table_name” ); … Read more