Removing the share buttons from listing sidebar
This topic contains 14 replies, has 6 voices, and was last updated by Paolo 10 years ago.
We have moved to a support ticketing system and our forums are now closed.
Open Support TicketTagged: filters, listing sidebar
-
AuthorPosts
-
June 28, 2014 at 8:02 pm #6644
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.
June 28, 2014 at 8:35 pm #6646In 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
June 29, 2014 at 1:12 am #6663Aha! 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!*
June 29, 2014 at 1:47 am #6665I 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! 🙂
June 29, 2014 at 1:52 am #6666This reply has been marked as private.June 29, 2014 at 3:08 am #6671I will for sure post when I get things up and running more – I want the review to say more than great help from support 🙂
August 27, 2014 at 2:28 am #13280hi 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
August 27, 2014 at 4:47 pm #13355Hi 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
November 5, 2014 at 11:07 pm #20770Paolo, could you kindly tell me which file I need to edit? I didn’t quite get that from the conversation. Thanks!
November 6, 2014 at 5:08 pm #20834Hi 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
November 13, 2014 at 6:52 pm #21448Thanks for this it really helped 🙂 Is there any chance of the code to also remove the ‘ShareThis’ element please?
Thanks
NicolaNovember 14, 2014 at 4:13 pm #21526Hi,
that’s easy, just remove :
'geodir_share_this_button',
from the array in the code provided above.
Thx
November 14, 2014 at 5:21 pm #21538I love it when you tell me things are easy….and they are 🙂
Thanks Paolo!
February 19, 2015 at 3:55 am #31343how upgrade friendly is this approach?
I would like to disable the share and charters as well.
February 19, 2015 at 3:41 pm #31417100% update safe.
-
AuthorPosts
We have moved to a support ticketing system and our forums are now closed.
Open Support Ticket