Term Array Sorting

Hi I am building out a site to list vinyl records for sale (Beatles, Bruce Springsteen, etc) I added tags and a terms query so I can pull up specific artists using a button; no problem there. But I need to sort them correctly so the Beatles are in the "B"s and Bruce Springsteen is in the "S’s. No problem there, I added an ACF field for sorting.

But I do not know how to build the query string array that will pull the product tags and allow me to custom sort. Can you help ?
https://fortherecordshop.com/overstock/

Hello @jdreznes,

Thanks for writing to us.

Please have a look at our doc to learn more about how to write looper query strings.

You can also check these threads as well to learn more about query strings


Hope it helps
Thanks

Thanks for the response. Could you guide me on how to get the http_build_query() function to work?

Hi @jdreznes,

You need to create your query in PHP and then pass the Query String variable within the http_build_query function to get your desired Query String for Looper Provider.
As an example:

$query = array(
    'post_type'           => 'product',
    'post_status'         => 'publish',
    'ignore_sticky_posts' => 1,
    'posts_per_page'      => 2,
    'orderby'             => 'rand',
    'order'               => 'asc',
);

echo  http_build_query( $query ) ; //it will output the query string.

If you don’t have any PHP compiler, you can use any online PHP Compiler for this.

Hope it helps.
Thanks

Thanks as you can see I’m no coding expert, but I think I can figure out what I need to do if you can provide me with a the PHP to list all product tags.

You are most welcome, @jdreznes.

one last request if you don’t mind? Could you send me the PHP code you used to write the “All Terms” loopewr provider shortcut?

Hello @jdreznes,

To display the terms of the Product tags you don’t need the PHP code, I would suggest you please use the Term element.

Test-Page-Cornerstone (89)

Now you need to go to the Customize —>Looper Provider —>taxonomy—>Product Tags.

Hope it helps
Thanks

this is very helpful but my objective is to get only the terms that are active for a certain product category.

Here is my example https://fortherecordshop.com/

I want to use the terms as to filter the page results but using this method lists “All Terms” My goal is to list
All Terms > only in a selected category > sorted using an ACF field I think I can build it using PHP if I had your PHP code as a starting point for All Terms as my template

Hello @jdreznes,

You can use Looper Provide Current Terms instead:

Hope this helps.

Current terms give me no value. Do I have to assign the product category in another looper up the chain?

Hey @jdreznes,

If you want to show the terms of the current category, you may check this thread. It will give you an idea on how to display the subcategory of category.

Hope that helps.

First, thankyou for your patience in helping me with this request! I can add the hook and get the same result as I do when I use “All Terms-product tags” My goal is to filter my results to show just the product tags when a specified product category page is pulled up.

Also in your reference this i see this group field, but I do not see it on my end under custom query. I only see a hook fieldCapture|408x131

Hello @jdreznes,

There is no relationship between the categories and the tags. They are only connected to the product item. Both of these can be added to a product item so if you want to display specific tags, you need to get the product ID first and then you can get the category of the current product and the tags of this product item. You can only search with the following condition:

Display only items that have category “A” and are tagged as “This”:

Category is A AND
Tag is THIS 

Display all items that have a category “A” or all items that are tagged as “This”:

Category is A OR
Tag is THIS 

Hope this makes sense.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.