Are you a GenerateCustomer?

Do you have an active GP Premium or GenerateBlocks Pro license key?

Create a GenerateSupport account for GeneratePress and GenerateBlocks support in one dedicated place.

Create an account
Already have a GenerateSupport account? Login

Just browsing?

Feel free to browse the forums. Support for our free versions is provided on WordPress.org (GeneratePress, GenerateBlocks).

Want to become a premium user? Learn more below.

Disable element based on URL

  • Hi

    I am looking to disable a GP element based on the URL – is this possible?

    If not, is there any other way to disable an element on the woocommerce thank you page after an order is placed? We use a checkout header that is an element but after the order it is not relevant and so needs removing.

  • Hi there,

    the woo thank you page has its own Woocommerce endpoint:

    is_wc_endpoint_url( 'order-received' )

    And you can use it like so in a PHP Snippet to remove a GP Element:

    
    add_filter( 'generate_element_display', function( $display, $element_id ) {
        if ( ! function_exists( 'is_wc_endpoint_url' ) ) {
            return $display;
        }
    
        if ( 123 == $element_id && is_wc_endpoint_url( 'order-received' ) ) {
            return false;
        }
    
        return $display;
    }, 10, 2 );
    

    In the code the 123 is the ID of the element change that to match your elements ID

  • Worked perfectly – thank you!

  • Glad to hear that!

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.