Hide grid view selections

This topic contains 15 replies, has 4 voices, and was last updated by  Barbara Magee 5 years, 4 months ago.

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

Open Support Ticket

Tagged: ,

  • Author
    Posts
  • #494988

    Barbara Magee
    Expired Member
    Post count: 146

    Hello,
    The gridview List-view option is now missing from our front end gridview selector. I went to the forum and discovered the addition of gridview-1 in the most recent GD update, which is creating the wonky layout mentioned by others in the forum.

    We are launching our new site tomorrow and just saw the blog post about the new Gridview-1. Besides hiding the new Gridview-1 we also wish to hide gridview select options 4 and 5 on the front end. How would we amend this code to include 4 and 5. We don’t wish to disable 1,4,5 completely, just hide them on the front end.

    add_filter(‘geodir_layout_options’,’_my_remove_layout_options’,10,2);
    function _my_remove_layout_options($layouts,$frontend){
    if($frontend){
    unset($layouts[“1”]);
    }
    return $layouts;
    }

    Thanks for your super support! Writing a review is on our to-do list after we go live.

    #494990

    Barbara Magee
    Expired Member
    Post count: 146

    On the same subject, my developer tried adding this code and got a white screen error:

    add_filter(‘geodir_layout_options’,’_my_remove_layout_options’,10,2);

    function _my_remove_layout_options($layouts,$frontend){

    if($frontend){

    unset($layouts[“1”]);

    }

    return $layouts;

    }

    #495021

    Alex Rollin
    Moderator
    Post count: 27815

    Hello,

    I will flag your question for the developers to let us know if there is a workaround for that.

    The original code snippet can be found here, for reference: https://wpgeodirectory.com/release-of-geodirectory-v-2-0-0-61/

    #495037

    Barbara Magee
    Expired Member
    Post count: 146

    Yes, that is the code I gave my developer. Does it make a difference if the code is double-spaced when they try to add it?

    #495070

    Kiran
    Moderator
    Post count: 7069

    Hello Barbara,

    Try following PHP snippet to hide layout options.

    
    
    function gd_snippet_240619_layout_options( $layouts, $frontend ) {
    	if ( $frontend ) {
    		//unset( $layouts["0"] ); // Hide List view
    		unset( $layouts["1"] ); // Hide Grid View (One Column)
    		//unset( $layouts["2"] ); // Hide Grid View (Two Columns)
    		//unset( $layouts["3"] ); // Hide Grid View (Three Columns)
    		//unset( $layouts["4"] ); // Hide Grid View (Four Columns)
    		//unset( $layouts["5"] ); // Hide Grid View (Five Columns)
    	}
    
    	return $layouts;
    }
    add_filter( 'geodir_layout_options', 'gd_snippet_240619_layout_options', 10, 2 );

    Kiran

    #495238

    Barbara Magee
    Expired Member
    Post count: 146

    Hi guys,
    Here is the response from my developer when they try to add the code you provided:
    “This is a function, not CSS, and somewhere in the copy/paste ' replaced code. This takes your site down as is. Can you share it again with those codes replaced with whatever it should be?”

    Thanks!

    #495390

    Alex Rollin
    Moderator
    Post count: 27815

    You can add the code with the Code Snippets plugin. There is not a CSS solution available for this outcome.
    https://wpgeodirectory.com/docs-v2/faq/customizing/#custom-code

    #496191

    Barbara Magee
    Expired Member
    Post count: 146

    We have added the snippets to the functions and did not get any errors. However, View Grid 1, 4 and 5 (the views we are attempting to hide) are still displaying on the front end. My developer is asking “what modifications are needed for their function in order to give the correct layout?”

    Your link from above is no longer working: https://wpgeodirectory.com/docs-v2/faq/customizing/#custom-code

    Thanks!

    #496351

    Naveen Giri
    Moderator
    Post count: 1559

    Hi Badbara,
    Try below code to hide grid 1, 4,5 option. It is working on my local. also if you have any cache plugin. clear cache and browser cache.

    
    function gd_snippet_240619_layout_options( $layouts, $frontend ) {
    	if ( $frontend ) {
    		unset( $layouts["1"] ); // Hide Grid View (One Column
    		unset( $layouts["4"] ); // Hide Grid View (Four Columns)
    		unset( $layouts["5"] ); // Hide Grid View (Five Columns)
    	}
    
    	return $layouts;
    }
    add_filter( 'geodir_layout_options', 'gd_snippet_240619_layout_options', 10, 2 );
    
    #497170

    Barbara Magee
    Expired Member
    Post count: 146

    We’ve got that code in the functions file. The last line of that code is what identifies which options should show:
    ‘gd_snippet_240619_layout_options’, 10, 2

    What we need to know is what number/numbers to replace the 10, 2 with to show View Grid:List, View Grid:2 and View Grid:3 selection options on the front end.

    Thanks for your assistance!

    #497195

    Alex Rollin
    Moderator
    Post count: 27815
    #497421

    Barbara Magee
    Expired Member
    Post count: 146

    We’ve had the gd_loop_actions in the builder since the beginning of site development. What we are trying to do is hide the Grid view 1, 4 and 5 in the dropdown selector that are currently visible to the user on the front end.

    The Grid View:1 produces a wonky layout (see attached image), as mentioned by other GD users in the forum, and View 4 & 5 don’t fit in our column width very well, so we just want Grid View List, 2 and 3 available to users to change their layout view.

    #497549

    Alex Rollin
    Moderator
    Post count: 27815

    Hello,

    the snippet only hides, so, no need to adjust it to show. It does not appear to be active on the site (or it is not working as expected).

    Please share WP Admin and FTP credentials if we need to take a look.

    WordPress Credentials
    WP Admin Login URL:
    WP Admin Username:
    WP Admin Password:

    FTP Credentials
    FTP Host:
    FTP Port:
    FTP User:
    FTP Password:

    #499314

    Barbara Magee
    Expired Member
    Post count: 146

    Attached is a screenshot verifying the snippet is installed. However, the grid views we are attempting to hide from the “View:grid selector are still displaying on the front end. Screenshot also attached.

    What do you suggest next to solve this?

    Thanks!

    #499319

    Naveen Giri
    Moderator
    Post count: 1559

    Hi @localdish,

    Where you have added the script code?

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

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

Open Support Ticket
20% Discount Offer
Hurry! Get your 20% discount before it expires. Get 20% Discount