Home Forums WoodMart support forum Search weight on Category page

Search weight on Category page

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #489592

    makexpertmodsrl
    Participant

    Hello, question!
    If I have a custom field Search Weight “pondere_cautare”, where can I put this code, so that my product with search weight appears first in the category?

    this is the code:
    <?php
    // …
    do_action( ‘woodmart_woocommerce_main_loop’ ); // Before this line

    // Custom sorting arguments
    $args = array(
    ‘post_type’ => ‘product’,
    ‘posts_per_page’ => -1, // Show all products in the current category
    ‘orderby’ => ‘meta_value_num’, // Sort by numeric value of the meta field
    ‘meta_key’ => ‘pondere_cautare’, // Name of the custom field
    ‘order’ => ‘DESC’, // Descending order
    );

    $query = new WP_Query( $args );

    if ( $query->have_posts() ) {
    while ( $query->have_posts() ) {
    $query->the_post();
    // Display product information here
    the_title(); // Product title
    the_excerpt(); // Product excerpt
    // …
    }
    wp_reset_postdata();
    } else {
    echo ‘No products found in this category.’;
    }

    // …
    ?>

    Thank you

    Attachments:
    You must be logged in to view attached files.
    #489952

    Hello,

    This is Woocommerce functionality, WoodMart theme does not influence that and our support does not cover customization of Woocommerce plugin.

    WoodMart is fully compatible with Woocommerce, at the same time any customization is beyond our support.

    If you have any questions please feel free to contact us.

    Best Regards

    #490132

    makexpertmodsrl
    Participant

    ok thankyou

    #490279

    You are welcome!

    Wish you a wonderful day!

Viewing 4 posts - 1 through 4 (of 4 total)

The topic ‘Search weight on Category page’ is closed to new replies.