post created but no permalink

Don’t insert into the database directly. Use the proper functions so that the posts are properly created before being inserted into the database. In your case the proper function is wp_insert_post(): wp_insert_post( array( ‘post_type’ => ‘books’, ‘post_title’ => ‘harrypotter’, ‘post_status’ => ‘publish’, ‘post_author’ => 1, ) ); The date field doesn’t need to be set … Read more

Get unique superset of taxonomy terms from a list of custom posts in another hierarchical taxonomy

Assuming that when you are on the “page” sub_category_1 you’re looking at a standard archive for that term, you can do this… The main query is already for the posts in sub_category_1 so get a list of their IDs: global $wp_query; $post_ids = wp_list_pluck( $wp_query->posts, ‘ID’ ); Then you simply need to get a list … Read more