[Resolved] Product attributes description on attribute page under the products

Home Forums Support [Resolved] Product attributes description on attribute page under the products

Home Forums Support Product attributes description on attribute page under the products

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #1153640
    retroreiz

    Hello everybody,

    how can I display the description of the attributes on the attribute page below products?

    Example: https://ibb.co/R4cRzgw

    Thank you in advance.

    Greetings, Andreas

    #1154251
    David
    Staff
    Customer Support

    Hi there,

    try this PHP snippet to move the Description on the Product Archives:

    add_action('woocommerce_archive_description', 'custom_archive_description', 2 );
    function custom_archive_description(){
        if( is_product_category() ) :
            remove_action('woocommerce_archive_description', 'woocommerce_taxonomy_archive_description', 10 );
            add_action( 'woocommerce_after_main_content', 'woocommerce_taxonomy_archive_description', 5 );
        endif;
    }
    #1154948
    retroreiz

    Hi David,

    many thanks for the answer.

    Unfortunately, this snippet only works on category descriptions. This snippet does not apply to attributes descriptions.

    What should the code be for the attributes archive page to work?

    Thanks and have a nice day.

    Greetings, Andreas

    #1155130
    David
    Staff
    Customer Support

    Do you need to move the description on all archives? so Category, Tags, Attributes etc
    Let me know

    #1156221
    retroreiz

    Hello David,

    only attributes.

    But if there is no other way, then also in categories, tags, attributes etc.

    Thank you.

    Greetings, Andreas

    #1156354
    David
    Staff
    Customer Support

    So i found this function:

    function my_is_wc_attribute() {
    
        /** 
         * Attributes are proper taxonomies, therefore first thing is 
         * to check if we are on a taxonomy page using the is_tax(). 
         * Also, a further check if the taxonomy_is_product_attribute 
         * function exists is necessary, in order to ensure that this 
         * function does not produce fatal errors when the WooCommerce 
         * is not  activated
         */
        if ( is_tax() && function_exists( 'taxonomy_is_product_attribute') ) { 
            // now we know for sure that the queried object is a taxonomy
            $tax_obj = get_queried_object();
            return taxonomy_is_product_attribute( $tax_obj->taxonomy );
        }
        return false;
    }

    Original source: https://wordpress.stackexchange.com/a/333460

    With that function added you should be able to do this:

    add_action('woocommerce_archive_description', 'custom_archive_description', 2 );
    function custom_archive_description(){
        if( my_is_wc_attribute() ) :
            remove_action('woocommerce_archive_description', 'woocommerce_taxonomy_archive_description', 10 );
            add_action( 'woocommerce_after_main_content', 'woocommerce_taxonomy_archive_description', 5 );
        endif;
    }
    #1156832
    retroreiz

    Hello David,

    you are great!!!!

    It works wonderfully 🙂

    Thank you very much.

    Greetings, Andreas

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