Support » Plugin: OnSale Page for WooCommerce » Onsale Page ID

  • Resolved bionutz

    (@bionutz)


    Hi,

    I need to know how I can get the new page ID (or slug) generated by the plugin so I can refer to it for some Widget Logic Conditions.

    For example the original page I make has ID 2121, I can refer to it with “is_page(2121)”. But when I select the page as “Onsale Page” from the settings the same argument is not working.

    Please help.
    Thank you.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author wpgenie2

    (@wpgenie2)

    Hi,
    Can you use?

    global $wp_query;
    if($wp_query->is_sale_page){
    
    }

    Hi,

    It doesn’t work.

    Plugin Author wpgenie2

    (@wpgenie2)

    Ok,
    put this in your theme function.php

    if ( ! function_exists( 'is_woocommerce_sale_page' ) ) :
    function is_woocommerce_sale_page(){
    	global $wp_query;
     
        if ( ! isset( $wp_query ) ) {
            _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
            return false;
        }
     
        return $wp_query->is_sale_page;
    }
    endif; 

    then you can use is_woocommerce_sale_page()
    Tested and it’s working, we will put this function in next update

    Working as intended.
    Thank you very much!

    Keep up the good work, you rock!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Onsale Page ID’ is closed to new replies.