Unable to customize templates

Dear HivePress Support Team,

I am currently working on a project using the ListingHive theme along with the HivePress plugin and have encountered a challenge that I require assistance with. I am attempting to customize the rendering of the listing_attributes_secondary block within the listing_view_page template. Specifically, my goal is to render these attributes in a table format, rather than the default layout provided by HivePress.

To achieve this, I have tried implementing a custom render callback function in my child theme’s functions.php file using the hivepress/v1/templates/listing_view_page/blocks filter. However, it appears that the render callback for the listing_attributes_secondary block is not being executed, as indicated by the absence of expected log messages in the debug.log file. From my understanding, you can only change the attributes present in the block but not add to it, so I cant achieve my goal using hooks.

Then I tried overriding the templates. I copied class-listing-view-page.php file and placed it under listinghive-child/hivepress/includes/templates. However, my changes are not applied to the page and HivePress still uses template from parent theme. What am I doing wrong?

Thank you for your time and support.

Best regards,

Nikita

I’m sorry for the delay. The best solution in this case is using the hivepress/v1/templates/listing_view_page filter hook to replace the listing_attributes_secondary block with a custom block or template part, and then implement any custom logic in this block or part. You can override blocks via the hivepress()->template->merge_blocks() helper, please check an example here https://github.com/hivepress/hivepress/blob/dee89a284412860c32e6c11957c295bd5cf0f9bb/includes/components/class-vendor.php#L435

Hope this helps.

Can you explain more specifically what should I override in order to change the html structure of the block? The existing parameters of the block do not allow that.

Okay, I figured the solution you suggested out and it worked eventually, thanks. I have put my PHP template file inside /htdocs/wp-content/plugins/hivepress/templates and specified the path.

The question is, wouldn’t it be lost once plugin updates?

Hi,

We do not recommend adding these changes this way, as they will be overwritten as soon as there is an update on our side, it is better to use a child theme for this purpose, please check this doc How to override template parts - HivePress Help Center

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