Change text and custom icon Favorite button

I want to change the icon and text for the favorite toggle.

image

  • Change the icon to a custom SVG one - not using the HivePress icons
  • Change “Add to Favorites” to “Save Listing”

Here’s the code:

add_filter(
	'hivepress/v1/templates/listing_view_page/blocks',
	function( $blocks, $template ) {
		$listing = $template->get_context( 'listing' );

		if ( $listing ) {
			$blocks = hivepress()->helper->merge_trees(
				[ 'blocks' => $blocks ],
				[
					'blocks' => [
						'listing_actions_primary' => [
							'blocks' => [
								'listing_favorite_toggle' => [
									'type'       => 'favorite_toggle',
									'_order'     => 20,
									'attributes' => [
										'class' => [ 'hp-listing__action', 'hp-listing__action--favorite', 'test'],
									],
									'captions' => [
										'Save Listing',
										'Remove Listing'
									],
									'icon' => 'map-marker'
								],
							],
						],
					],
				]
			)['blocks'];
		}

		return $blocks;
	},
	1000,
	2
);

I can’t find what keys I need to use, or could I change the whole block? i.e.

'content' => '<a>Save Search</a>'

Can someone help me out?

Hi,

We recommend changing the text through Loco Translate: How to change any static text - HivePress Help Center. As for the icon, it’s easier to do it with CSS: css - Is there a way to use SVG as content in a pseudo element ::before or ::after - Stack Overflow

No way to do this on the filter? Upon checking here,

Can see that it is being updated on the render, probably an issue here is the keys needed for this needs to be explicit.

image

Hi,

Please note that the easiest way to change the text is to use Loco Translate. You can use CSS tweaks, but unfortunately, we can’t help with this as it is out of our support scope.

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