Customizing PHP template with child theme

hello,
I want to change headline h4 to h6 in class-listing-view-block.php.
where I have to place the customized file in child theme?
I already tried this directories but does not overwrite:
childtheme-name/hivepress/includes/templates
childtheme-name/hivepress/includes
childtheme-name/hivepress

Hi,

Please make sure that you overwrite the template parts as shown in this documentation: How to override template parts - HivePress Help Center. Also, please check out this topic: Modify/add a block with listings to homepage? - #24 by James123

It the issue still exists, please provide more details (e.g., your actions step by step with screenshots, screencast, etc.). This will help us to reproduce and resolve the issue faster.

hello andrii, thanks for this links.
But the overrides from hivepress-plugin already works fine and I did like the instructions.
but in my case I want to overwrite some files from the listinghive theme, for example the post-archieve.php which is located at listingheive/templates. How can I overwrite this file / where I have to place the new file?
Thanks lot!

Hi,

Please note that templates are built as blocks and not plain HTML, but they can be changed or template parts can be overwritten here: hivepress/templates at master · hivepress/hivepress · GitHub, or if a part is missing, you can change anything, for example, for heading, using a PHP snippet:

add_filter(
	'hivepress/v1/templates/listing_view_block',
	function( $template ) {
		return hivepress()->template->merge_blocks(
			$template,
			[
				'listing_title' => [
					'tag' => 'h6',
				],
			]
		);
	},
	1000
);

I hope it helps

Im currently using this function to replace the Vendor Image with the Listing Image

add_filter(
	'hivepress/v1/templates/listing_view_block/blocks',
	function( $blocks, $template ) {
		return hivepress()->helper->merge_trees(
			[ 'blocks' => $blocks ],
			[
				'blocks' => [
					'listing_image' => [
						'path' => 'listing/view/block/listing-image',
					],
				],
			]
		)['blocks'];
	},
	1000,
	2
);

However, I am wondering if it is possible to use a listing attribute with type = attachment, such as field name = ‘logo’ and use the listing image as a fallback? Is this sort of function possible and would it require significant work to accomplish?

ok I want to overwrite the template part, but sorry - where I have to store the new file?
original path is for example here:
wp-content/themes/listinghive/templates/post-archive.php
where is the destination folder?
Thanks!

Did you try wp-content/themes/my-child_theme/templates/post-archive.php ?

1 Like

In case of the theme file (e.g. listinghive/templates folder or files in the theme folder itself) the path should be the same, e.g. child-theme/templates/post-archive.php. In case of HivePress plugin template parts (e.g. in hivepress/templates or listinghive/hivepress folders), please copy template parts to child-theme/hivepress/[relative path here]. So for the listing image to be overridden, you can copy hivepress/templates/listing/view/block/listing-image.php to child-theme/hivepress/listing/view/block/listing-image.php.

Hope this helps

Hi,

You need to overwrite the template part using the child theme, as shown in this topic. And already in the file you are overwriting, specify that if the logo is $listing->get_logo__url('thumbnail') (this is an example if the attribute has the name of the logo), then do this action, if not, then another action.

​I hope this is helpful to you

Thank you, this is helpful. And apologies, i thought I had created a new thread but somehow it was tacked onto this one.

Hi,

Sorry for the confusion. As these are the same topics, we simply merged them together.

1 Like