How to Use Custom Meta Field Instead of CPT Title in Post URL

You have to use a wp_update_post function and update the required fields based on available fields in WP_Post class. add_action( ‘save_post’, ‘wpse75679_save_post’ ); function wpse75679_save_post( $post_id ) { if( defined( ‘DOING_AUTOSAVE’ ) && DOING_AUTOSAVE ) return; // verify post is not a revision if ( ! wp_is_post_revision( $post_id ) ) { // unhook this function … Read more

WP_Query order by two values

I believe this is what your looking for. $q = new WP_Query( array( ‘meta_query’ => array( ‘relation’ => ‘AND’, ‘state_clause’ => array( ‘key’ => ‘state’, ‘value’ => ‘Wisconsin’, ), ‘city_clause’ => array( ‘key’ => ‘city’, ‘compare’ => ‘EXISTS’, ), ), ‘orderby’ => array( ‘city_clause’ => ‘ASC’, ‘state_clause’ => ‘DESC’, ), ) ); WP_Query

Get post ID of either existing post or new post

From the documentation for post_exists(): Return (int) Post ID if post exists, 0 otherwise. So you can get the ID just by assigning the result of post_exists() to a variable: $post_id = post_exists( $class_post_title ); The same thing works for wp_insert_post(): Return (int|WP_Error) The post ID on success. The value 0 or WP_Error on failure. … Read more

WordPress multisite – is it possible to have different taxonomies for each site?

Sure, you can. Each site in multisite is completely independent, so you can have completely different CPTs, taxonomies and… everything. The problem is that if you register the CPT via a plugin, and you enable it in all sites (or network-activate it) and you use the same plugin to register taxonomies, you’ll have same taxonomies … Read more