Removing the share buttons from listing sidebar

This topic contains 14 replies, has 6 voices, and was last updated by  Paolo 9 years, 3 months ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
  • Author
    Posts
  • #6644

    Jason Kadlec
    Free User
    Post count: 22

    first req – a bit outside the scope of support, but I hope you can help me learn a bit more about how to use filters —

    I want to modify this function I found in geodirectory_hooks_actions.php

    
    
    function geodir_detail_page_sidebar_content_sorting()
    {
    	$arr_detail_page_sidebar_content =
    	apply_filters('geodir_detail_page_sidebar_content' , 
    					array( 	'geodir_social_sharing_buttons',
    							'geodir_share_this_button',
    							'geodir_detail_page_google_analytics',
    							'geodir_edit_post_link',
    							'geodir_detail_page_review_rating',
    							'geodir_detail_page_more_info'
    						) // end of array 
    				); // end of apply filter
    	if(!empty($arr_detail_page_sidebar_content))
    	{
    		foreach($arr_detail_page_sidebar_content as $content_function)
    		{
    			if(function_exists($content_function))
    			{
    				add_action('geodir_detail_page_sidebar' , $content_function);	
    			}
    		}
    	}
    }

    I can get what I’m after by commenting out

    
    
    
    //'geodir_social_sharing_buttons',
    							//'geodir_share_this_button',

    But then of course I’m modifying the core plugin which I don’t want to do.

    I tried a few things in the functions.php – for example adding:

    remove_filter('geodir_detail_page_sidebar', 'geodir_social_sharing_buttons');

    I also tried this:

    
    
    function geodir_sidebar_custom() {
    						array( 	//'geodir_social_sharing_buttons',
    							//'geodir_share_this_button',
    							'geodir_detail_page_google_analytics',
    							'geodir_edit_post_link',
    							'geodir_detail_page_review_rating',
    							'geodir_detail_page_more_info'
    							); // end of apply filter
    }
    add_filter('geodir_detail_page_sidebar_content', 'geodir_sidebar_custom')
    

    Neither had the intended effect.

    In the original code – it’s a variable which is then pulling a filter which is itself an array of functions… pretty nesty!

    My theme has share buttons baked in already that look really nice so that’s why I’m trying to hide them.

    FWIW – a feature request is to just turn those into widgets as well… it would make things more plugin-like and less theme like — I was surprised those elements where so baked in when the other elements in the listing side bar are widgeted – the my dashboard, map and popular listing stuff.

    Thank you for helping me with a little copy paste code or refer me to a better tutorial – I’ve been through the codex and a few other tuts out there – but clearly not got my head around how to apply what I’ve learned to this situation.

    #6646

    Paolo
    Site Admin
    Post count: 31206

    In this post I describe a similar situation: https://wpgeodirectory.com/support/topic/disable-select-map-view/

    Basically what you want to do is:

    
    
    
    // remove the orginal action entirely
    
    remove_action('geodir_detail_page_sidebar', 'geodir_detail_page_sidebar_content_sorting', 1);
    
    // add a new action 
    
    add_action('geodir_detail_page_sidebar', 'geodir_detail_page_sidebar_content_sorting_custom', 1);
    
    // copy the orginal function, rename it and comment the code you wish to hide
    
    function geodir_detail_page_sidebar_content_sorting_custom()
    
    {
    	$arr_detail_page_sidebar_content =
    
    	apply_filters('geodir_detail_page_sidebar_content' , 
    
    					array( 	'geodir_share_this_button',
    
    							'geodir_detail_page_google_analytics',
    
    							'geodir_edit_post_link',
    
    							'geodir_detail_page_review_rating',
    
    							'geodir_detail_page_more_info'
    
    						) // end of array 
    
    				); // end of apply filter
    
    	if(!empty($arr_detail_page_sidebar_content))
    
    	{
    
    		foreach($arr_detail_page_sidebar_content as $content_function)
    
    		{
    
    			if(function_exists($content_function))
    
    			{
    
    				add_action('geodir_detail_page_sidebar' , $content_function);	
    
    			}
    
    		}
    
    	}
    
    }
    
    

    I totally removed ‘geodir_social_sharing_buttons’, from the array.

    Hope this helps!

    Thx

    #6663

    Jason Kadlec
    Free User
    Post count: 22

    Aha! Completely obvious now that I see it… I was thrown off by trying to remove the filter didn’t realize I could just remove the entire action and recreate. Nice!

    Thank you @paolo!

    BTW I’m integrating this with the Salient theme – it’s looking really nice.

    I’m going to replicate how Salient will either put your images up top or if a video is present, then the video goes up top.

    For Salient theme – it’s for their “portfolio” but I liked the look of it.

    Anyhoo – one more tick box checked.. now onto the image vs video!

    *topic resolved*

    *impressed by fast response on Saturday!*

    #6665

    Paolo
    Site Admin
    Post count: 31206

    I was around working on my directory. It’s a pleasure to spare some time to help, especially if it allows to write replies to use for the docs as example…

    Tomorrow I’ll take it off though! 🙂

    #6666

    Paolo
    Site Admin
    Post count: 31206
    This reply has been marked as private.
    #6671

    Jason Kadlec
    Free User
    Post count: 22

    I will for sure post when I get things up and running more – I want the review to say more than great help from support 🙂

    #13280

    jaciando
    Free User
    Post count: 43

    hi there – can i please jump in on this – i would like to also remove the current social share buttons etc that appears in listing detail sidebar and add my own (well.. addthis) social share icons instead. so i really dont know anything about php – and dont want to modify the original file – but could you please just clarify what i would need to do to remove this entirely – in child theme? thanks so much

    #13355

    Paolo
    Site Admin
    Post count: 31206

    Hi Jaciando,

    In this post (plus the one linked above) I explain exactly what you are looking for.

    How to remove/edit elements in the detail page sidebar.

    If by reading thiese posts you are still not confident editing the php file on your own, you should hire someone to do it for you, because it can be explained any simpler.

    Thx

    #20770

    jeffreyr
    Buyer
    Post count: 1

    Paolo, could you kindly tell me which file I need to edit? I didn’t quite get that from the conversation. Thanks!

    #20834

    Paolo
    Site Admin
    Post count: 31206

    Hi Jeffrey,

    You’d add the code above to your theme functions.php file.

    The plugin is made so that its functions can be modified without modifying it’s file.

    Files of the plugin should never be modified.

    Let us know,

    Thx

    #21448

    nicolalucie
    Free User
    Post count: 33

    Thanks for this it really helped 🙂 Is there any chance of the code to also remove the ‘ShareThis’ element please?

    Thanks
    Nicola

    #21526

    Paolo
    Site Admin
    Post count: 31206

    Hi,

    that’s easy, just remove :

    'geodir_share_this_button',

    from the array in the code provided above.

    Thx

    #21538

    nicolalucie
    Free User
    Post count: 33

    I love it when you tell me things are easy….and they are 🙂

    Thanks Paolo!

    #31343

    BL Interactive
    Expired Member
    Post count: 83

    how upgrade friendly is this approach?

    I would like to disable the share and charters as well.

    #31417

    Paolo
    Site Admin
    Post count: 31206

    100% update safe.

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

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket