Skip Navigation

[Resolved] Custom post type category select field

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 0 replies, has 1 voice.

Last updated by georgiI 1 month, 3 weeks ago.

Assisted by: Minesh.

Author
Posts
#2783119
3.PNG
2.PNG
1.PNG

Hi, I'm working on a website for real estate and other plugin made custom post type - listings. I need to make a select of their category and use it in a post form.

So far I've added city field, that is also non toolset created field and it's working, however no matter what I do the listing categories do not work correctly.
All categories should show one of four on post view and be called out by searched using toolset search filter.

All 4 listing categories are created trough wordpress.

#2783136

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Can you please share details what form you created and what terms you want to display with what taxonomy and where you added the form.

Maybe step by step information with links what is not working and what is your expected result would help.

Please share admin access details as well as frontend user access details if required.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

#2783621

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Well - see you created the following form:
- hidden link

The form is used to create new post type "post".

When I checked the "post" post type, it does not have listing_category taxonomy assigned.

And I see even you added the listing_category as generic field.

<label for="%%FORM_ID%%_listing_category">[cred_i18n name='listing_category-label']Категория[/cred_i18n]</label>
[cred_generic_field type='select' field='listing_category' class="" urlparam=""]
          {
"required":1,
"persist":1,
"default":["Други движими вещи"],
"options":[{"value":"Други движими вещи","label":"Други движими вещи"},{"value":"Машини и съоръжения","label":"Машини и съоръжения"},{"value":"Недвижими имоти","label":"Недвижими имоти"},{"value":"Превозни средства","label":"Превозни средства"}]
}
[/cred_generic_field]

I'm not sure why you created this.

You setup listing_category as custom field for post type "post".

Do you mean you want to assign selected listing_category to listing_category taxonomy? if yes, then first thing you will have to do is, you should assign listing_category taxonomy to display with post type "post" and after that we can add the taxonomy field with the above form and then we will check.

Does that makes sense?

#2783642
11.PNG

Hi, it's very complicated, but you mean this, right?
Because there are no other categories available, since listings is created with other plugin.

#2783666

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

This is not actually Toolset issue but I'm glad to say that I found more reliable solution for you.

I've added the following code to your active theme's functions.php file:
=> hidden link

function func_attach_listing_category_to_post_postype() {
	register_taxonomy_for_object_type( 'listing_category', 'post' );
}
add_action( 'init', 'func_attach_listing_category_to_post_postype', 10 );

As you can see now, you should be able to see the "Listing Category" with your post type "post" just after "Add New Post" link on left admin bar:
- hidden link

Now, you just edit your form:
- hidden link

And try to add the listing category taxonomy as field by clicking on the "Add Fields" button.
- hidden link

For example:

[cred_field field='listing_category' force_type='taxonomy' output='bootstrap' display='select' single_select='true']

Now, you should try to create a new post using the above form and check if you able to save the listing category as expected.

#2783697

Minesh, you're a life-saver!

That works, thank you.