Several different category-specific Add Listing pages

Hi. Instead of one “Add Listing” button for all categories, I need a separate page for each category. I tried to implement this with the following js code:

document.addEventListener('DOMContentLoaded', function() {
    var params = new URLSearchParams(window.location.search);
    var categoryId = params.get('category');

    if (categoryId) {
        var selectElement = document.querySelector('select[name="categories"]');

        if (selectElement) {
            selectElement.value = categoryId;

            if ($(selectElement).data('select2')) {
                $(selectElement).trigger('change');
            }
        }
    }
});

But it doesn’t work exactly as needed. When navigating to the link website.com/submit-listing/details/?category=20, ?category=26, or ?category=28, the value of the Category field changes correctly. However, the corresponding fields and checkboxes that are supposed to appear based on the selected category do not show up. Ideally, when a specific category is selected via the URL, all related fields and options for that category should be automatically displayed on the form.

Can you tell me how to solve the problem?

Thanks.

Hi,

Unfortunately, we can’t help you with the generation of different pages, as this requires testing and advanced customization. But, as a workaround, please try using this PHP snippet: Enable the Select Category page (deprecated) in the Add Listing process #hivepress #listings · GitHub, and there you can copy the category-specific URLs and use them. You will be immediately redirected to the category-specific form.

​I hope this is helpful to you.

Andrii, I have the same requirement as the OP. Could you expand a little on how the snippet can be used?

Hi,

This snippet adds the category selection after you click Add Listing as an additional step.