So I found an old post about how to limit categories…but I’m not sure how to limit categories and tags? Once I use the code, it erases the ability to select any tags while making a blog. How can I choose what categories and tags are allowed from the front end?
Here is the code that works great with categories but I’m stumped on the blog…
function buddyblog_show_custom_cats( $settings ) {
$tax = array();$tax[‘category’] = array(
‘taxonomy’ => ‘category’,
‘view_type’ => ‘dd’,
‘child_of’ => 29, //CHAGE It with the correct ID,
‘orderby’ => ‘slug’,
‘order’ => ‘ASC’
);$settings[‘tax’] = $tax;
return $settings;
}Hi Ken,
Thank you for posting.Please allow me to post the code tomorrow.
Thank you
BrajeshHi Ken,
I am sorry I missed it. I will post the code today(Around noon PST).Thank you
BrajeshHi Ken,
hope you are doing fine.Please use the following code and modify the term ids with your own to include only them.
function buddyblog_limit_terms( $settings ) { if ( ! isset( $settings['tax'] ) ) { return $settings; } $tax = $settings['tax']; //it is multi dimensional array $taxonomy = 'category';//name of taxonomy // Array of term ids to include. $terms = array(1, 53 ); //term ids if( ! isset( $tax[ $taxonomy ] ) ) { $tax[ $taxonomy ] = array(); } $tax[ $taxonomy ]['include'] = $terms; //update settings $settings['tax'] = $tax; return $settings; } add_filter( 'buddyblog_post_form_settings', 'buddyblog_limit_terms' );
Hope that helps.
Brajesh
Hi Ken,
Sure we can. here is the updated code from the above example.function buddyblog_limit_terms( $settings ) { if ( ! isset( $settings['tax'] ) ) { return $settings; } $tax = $settings['tax']; //it is multi dimensional array $tax_terms = array( 'category'=> array(1, 53 ), // tax_name=> term_ids 'post_tag' => array( 7, 9 ), //add as you please, //you can add other taxonomy too ); foreach ( $tax_terms as $taxonomy => $terms ) { if ( ! isset( $tax[ $taxonomy ] ) ) { $tax[ $taxonomy ] = array(); } $tax[ $taxonomy ]['include'] = $terms; } //update settings $settings['tax'] = $tax; return $settings; } add_filter( 'buddyblog_post_form_settings', 'buddyblog_limit_terms' );
It is simplified to use multiple taxonomies.
Hope that helps.
The topic ‘ [Resolved] Buddyblog – How to limit Categories and Tags?’ is closed to new replies.