Add listing button to the account/listings overview page

At the top or bottom of the account/listings overview page I would like to have a button that say “create new listing”. This will greatly improve the UX for vendors, and the feeling that they “operate” from their account page.

Currently, the only way I find to do this is editing the hivepress/template listings (edit), however this method is lacking as it is almost impossible to recreate the default layout / setup due to missing components. Like the single div with hp-row class. I could use the gutenberg editor to add raw html blocks before and after the hivepress blocks, but it’s way too hacky and too much maintenance.

Is there any way to make it happen? It should be a small and needed implementation that I bet most users would agree with, and that should make it into the default hivepress package/setup without requiring customization.

Thank you :slight_smile:

Hi,

There is a button in the header with the same function - Add Listing, if you have not removed it, it is displayed on every page.

To add this button, you will need to create a PHP snippet using this hook hivepress/v1/templates/listings_edit_page, you can check samples here Search · hivepress/v1/templates · GitHub

​I hope this is helpful to you.

Here is the solution if anyone else needs:

add_filter(
    'hivepress/v1/templates/listings_edit_page',
    function ($template) {
        $addListingUrl = home_url('/add-listing/');

        return hivepress()->helper->merge_trees(
            $template,
            [
                'blocks' => [
                    'page_content' => [
                        'blocks' => [
                            'vendor_listing_submit_link' => [
                                'type' => 'content',
                                'content' => '<div>
                                <a class="juppi-link" href="' . $addListingUrl . '">Opprett en ny tjeneste</a>
                                </div>',
                                '_order' => 15,
                            ],
                        ],
                    ],
                ],
            ]
        );
    },
    1000
);

3 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.