Issue with loading category via API

Hello all, I am hoping I could get some help here. I’ve been at this for a few days and just cant figure it.

I am trying to upload new listings via API. I created a custom endpoint and exposed all necessary fields. When I load new listing EVERYTHIG but category is loaded without any issues. When I attempt to look at listings via Postman I can see categories for listing loaded via regular import process but listings which were loaded though API do not have category. is there a special way category field needs to be handled?

Thank you

Hi,

If possible share the code snippet if it’s a custom REST API endpoint. If it’s the default WP REST API posts endpoint, then categories should be set as taxonomy terms of “hp_listing_category” taxonomy, please make sure that assigned term IDs are correct.

I was able to get this figured out but now I am stuck on images. I am able to successfully load images however the challenge I am facing having them all assigned to a listing. When API script is loading 5 images only one is showing up on a listing page. Thank you

Please check these suggestions:

Either setting 2 meta field values or updating the plugin installation time should resolve the issue, along with disabling the cache temporarily.

Thak you very much Ihor! this helped a lot. One minor issue I am facing now is that count of items in the category is not displaying correct count. Should i be updating an additional field in DB for this counter to work?

It’s probably because of caching, if the import process doesn’t trigger the “update” event for each listing. Please try re-saving one of the listings assigned to the category, this should refresh the listing count for the category.

Thank you Ihor I attempted resaving a listing and that didn’t help. The strange thing is that everything is working fine for subcategories but the parent category doesnt show total count.
Parent category shows 529 listings but subcategories show a lot more


You can try using this snippet to check if this is related to caching:

define('HP_CACHE', false);

I checked the listing count function and it seems to be ok, it should also include parent categories hivepress/includes/components/class-listing.php at master · hivepress/hivepress · GitHub After adding the code snippet for disabling cache, please try to re-save one of the listings assigned to the category again. The page itself may also be cached as static HTML, for example by third-party plugins like LiteSpeed.