Join our new community forum for support & discussion

Join Now

Home Support Themes ListingHive Hide Claim Listing Link

Hide Claim Listing Link

  • Author
    Posts
  • Cindabella

    Hi ihor, I would like to hide the Claim Listing link on some of my categories and their sub-categories. Is this a future feature or can it be done with a CSS snippet.

    Love your free theme and extensions, thank you. 🙂

    ihor developer

    Please try using this code snippet, replace “1,2,3” with category IDs:

    add_filter(
    	'hivepress/v1/templates/listing_view_page/blocks',
    	function( $blocks, $template ) {
    		$listing = $template->get_context( 'listing' );
    
    		if ( $listing && array_intersect( $listing->get_categories__id(), [ 1, 2, 3 ] ) ) {
    			$blocks = hivepress()->helper->merge_trees(
    				[ 'blocks' => $blocks ],
    				[
    					'blocks' => [
    						'listing_claim_submit_link' => [
    							'type' => 'content',
    						],
    					],
    				]
    			)['blocks'];
    		}
    
    		return $blocks;
    	},
    	1000,
    	2
    );

    You can add it via the Code Snippets plugin https://wordpress.org/plugins/code-snippets/

    jaimevivesfilms

    Hey @Cindabella,

    I want to hide the Claim Listing button too. Did you achieve it by doing what @ihor said?

    I added the code snippet on Snippet>Add New>and then pasted it under the “Code” tab, but the link didn’t hide.

    Let me know if it worked for you please!

    Thanks legends.

    ihor developer

    @jaimevivesfilms If you want to hide it globally you can simply disable the Claim Listings extension, but if you mean hiding it for some specific categories please make sure that you replaced “1,2,3” with the category IDs where you want it to be hidden.

    Cindabella

    @ihor thank you it worked perfectly. 🙂


    @jaimevivesfilms
    replace the 1, 2, 3 with the categories you don’t want to show it on. I used the plugin that @ihor suggested and works. Make sure you tick – add snippet everywhere. Good luck 🙂

    Cindabella

    @igor is it possible to hide the date as well? “ADDED ON MARCH 23, 2021”

    serhii developer

    @Cindabella please try using the CSS code snippet suggested in this topic – https://hivepress.io/support/topic/how-do-i-remove-the-date-from-the-listings/

    Cindabella

    @serhill Thanks but that would remove the date on all listings.

    I would prefer to remove the date on certain categories, is that possible?

    Cindabella

    @serhii sorry not @serhill 🙂

    ihor developer

    In this case please try using the following code snippet instead:

    add_filter(
    	'hivepress/v1/templates/listing_view_page/blocks',
    	function( $blocks, $template ) {
    		$listing = $template->get_context( 'listing' );
    
    		if ( $listing && array_intersect( $listing->get_categories__id(), [ 1, 2, 3 ] ) ) {
    			$blocks = hivepress()->helper->merge_trees(
    				[ 'blocks' => $blocks ],
    				[
    					'blocks' => [
    						'listing_claim_submit_link' => [
    							'type' => 'content',
    						],
    
    						'listing_created_date' => [
    							'type' => 'content',
    						],
    					],
    				]
    			)['blocks'];
    		}
    
    		return $blocks;
    	},
    	1000,
    	2
    );
    Cindabella

    Unfortunately that one didn’t work @ihor 🙁
    What could I be doing wrong?

    ihor developer

    Should work for the single listing pages, if you mean the listing search pages you can try using the same snippet but replace “listing_view_page” with “listing_view_block”.

    Cindabella

    Thanks. Understand now and it’s all working. 🙂

    Hanna

    Hi,
    Can the claim listing link be hidden in all listings except in the ones made by admin? (So the claim listing link would be visible only in listings that are made by the admin)
    Thanks!

    yevhen developer

    Please try this PHP snippet

    add_filter( 
    	'hivepress/v1/templates/listing_view_page/blocks',
    	function($blocks, $template){
    		$listing = $template->get_context('listing');
    		
    		if($listing && !user_can($listing->get_user__id(), 'manage_options')){
    			$blocks = hivepress()->helper->merge_trees(
    					[ 'blocks' => $blocks ],
    					[
    						'blocks' => [
    						    	'listing_claim_submit_link' => [
    									'type' => 'content',
    						    	],
    					     	],
    				]
    				)['blocks'];
    		}
    		
    		return $blocks;
    	},
    	1000,
    	2
    );
    Hanna

    Perfect, this works! Thanks so much!

Viewing 16 posts - 1 through 16 (of 16 total)

New Reply

This forum has been archived and is no longer accepting new posts or replies. Please join our new community forum for support & discussion.