Bilene kolaydır muhtemelen ama ben php den hiç anlamadığım için çözemedim. Woocommerce sitemde ürünlerde aşağıdaki tarzda açıklamalara renk ve konuları otomatik çektiğim tıklanabilir linkler var.


Bu linklere tıkladığında normalde filtre sayfasına gitmesi lazım, örneğin black e tıkladığında filtreye gidip siyah renkli ürünlerin otomatik çıkması lazım ama link yapısı bozuk olduğundan ana sayfaya yönlendiriyor. Aşağıdaya bozuk olan link yapısını ve olması gereken link yapısını ekliyorum:

2 çeşit niteliğim var biri renk biri konu:

Çalışmayan yapı:
/?taxonomy=pa_color&term=red
/?taxonomy=pa_subject&term=landspace
Sitemde çalışan yapı (tıkladığımda bu şekilde yönlenmeli ki çalışsın):
/shop/?product_cat=digital-prints&filter_color=red
/shop/?product_cat=digital-prints&filter_subject=landspace



Aşağıya functions.php deki ilgili kod kısmını ekliyorum:

/* for Attributes Shortcode */
function so_39394127_attributes_shortcode( $atts ) {

    global $product;

    if( ! is_object( $product ) || ! $product->has_attributes() ){
        return;
    }

    // parse the shortcode attributes
    $args = shortcode_atts( array(
        'attributes' => array_keys( $product->get_attributes() ), // by default show all attributes
    ), $atts );

    // is pass an attributes param, turn into array
    if( is_string( $args['attributes'] ) ){
        $args['attributes'] = array_map( 'trim', explode( '|' , $args['attributes'] ) );
    }

    // start with a null string because shortcodes need to return not echo a value
    $html = '';

    if( ! empty( $args['attributes'] ) ){

        foreach ( $args['attributes'] as $attribute ) {

            // get the WC-standard attribute taxonomy name
            $taxonomy = strpos( $attribute, 'pa_' ) === false ? wc_attribute_taxonomy_name( $attribute ) : $attribute;

            if( taxonomy_is_product_attribute( $taxonomy ) ){

                // Build the html string with the label followed by a clickable list of terms.
                // Updated for WC3.0 to use getters instead of directly accessing property.
                $html .= get_the_term_list( $product->get_id(), $taxonomy, '<span>' . $attribute_label . '' , ', ', '</span>' );
            }

        }

        // if we have anything to display, wrap it in a <ul> for proper markup
        // OR: delete these lines if you only wish to return the <li> elements
        if( $html ){
            $html = '<span>' . $html . '</span>';
        }

    }

    return $html;
}
add_shortcode( 'display_attributes', 'so_39394127_attributes_shortcode' );


Vakit ayırabilecek biri varsa şimdiden teşekkür ederim.