Tagged: categories, custom post type, UI
Hello,
Thanks for all the help so far.
I have another problem.
When setting up a form for a custom post type, the line
allowed_categories' => get_all_category_ids(),
Doesn’t show any UI/check boxes for the user to select categories for their custom post type post.
Any ideas? Thanks!
Hi Brendan,
For custom taxonomy you will need to have the ids from that taxonomy. The solution is to useget_terms with taxonomy and fields=>’ids’ in the arguements.
https://developer.wordpress.org/reference/functions/get_terms/
Regards
BrajeshI’m not sure what you mean. When I register the custom post types, they share categories and tags with normal blog posts. should it not just work?
Can you give me an example of what to add to the form setup that would allow categories and tags for the post type ‘community-story’ (slug)
Being able to exclude certain categories from the front end post would be nice as well.
I think I can take it from there.
Hi Brendan,
Please allow me till tomorrow to post the code.Thank you
BrajeshHello Brendan,
Please check the following example code. it might help you.
/** * Register a custom Form * */ function my_post_form() { $settings = array( 'post_type' => 'book', // Replace it with your custom post type. // Which post type. 'post_author' => bp_loggedin_user_id(), // Who will be the author of the submitted post. 'post_status' => 'publish', // How the post should be saved, change it to 'publish' if you want to make the post published automatically. 'current_user_can_post' => is_user_logged_in(), // Who can post. 'show_categories' => true, // Whether to show categories list or not, make sure to keep it true. 'tax' => array( 'category' => array( 'taxonomy' => 'category', 'view_type' => 'checkbox', 'include' => array( 1, 31 ), // Replace categories ids you want to show. ), ), ); bp_new_simple_blog_post_form( 'my form', $settings ); } add_action( 'bp_init', 'my_post_form', 4 );
Thank You
Ravi
You must be logged in to reply to this topic.