Forums

Need help building query based on prices in custom fields (2 posts)

  1. orjueladiego
    Member
    Posted 1 year ago #

    I am very acquainted with WP but am not a PHP developer. I am stuck with some something that my skills won't allow me to execute.

    In short, this is the issue: I am using WP posts to review technology products. For each post (product) I have a custom field with the product's price, for example $150 (the custom field does not include the dollar sign, in this case just 150).

    I need to create a list that will reside in the sidebar that generates a search result with products whose price fall in a range. For example, I might have the following list in the sidebar:

    Find products by price:
    $0 - $99 (link)
    $100 - $199 (link)
    $200 - $299 (link)

    The result of clicking any of those three links would list the products that fall in the range as per the price I put in the custom field. So, clicking on $0 - $99 would display in a search result all the products that have a price between $0 and $99 in the custom field "Price", for example, a product costing $55 and others like it.

    I hope I've provided enough information.

    Any ideas?

    Thanks!

  2. gymgangsta
    Member
    Posted 1 year ago #

    I set up a Parent Category: Price

    with Child Categories:
    — $ 0.00 - $ 100.00
    — $ 100.00 - $ 200.00
    — $ 200.00 - $ 300.00

    I put this code into my sidebar

    <!-- Price Code -->
    <h2>Browse By All Inclusive Price</h2>
    <?php wp_list_categories('orderby=id&show_count=1
    &child_of=18&title_li='); ?>
    <!-- End Price Code -->

    18 is the ID for my Parent Category.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.