Skip Navigation

[Resolved] Cannot figure out how to make taxonomy term archive pages with parametric search

This support ticket is created 8 years ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Tagged: 

This topic contains 10 replies, has 2 voices.

Last updated by Beda 8 years ago.

Assisted by: Beda.

Author
Posts
#364550

Jay

Hello,

I've been enjoying learning Toolset and have been working for a few months on site.

While I have indeed benefited from the classifieds and real estate demos you provide for learning Toolset, I've been unable to really apply the demo setup configurations to my own needs.

My site's content shall be generated from the frontend using a CRED post form. Posting to the site is completely free, so I'm not using woocommerce along with CRED. And just a note, I am not using the Layouts plugin. Just Types, Views, CRED and Access.

The site is like a classifieds listing site which users view or create listings in a single appropriate listing category.

I have the following CPT:
--> Listings (slug: listing)

Then I have a heirarchical taxonomy tied to the Listings CPT:
--> Categories (slug: cat)

Then, for my "Category" taxonomy terms which I use for the site's listing categories, I have the following:

Clothing, Footwear & Outerwear
---> slug: clothing-footwear-outerwear

Jewelry, Purses & Accessories
---> slug: jewelry-purses-accessories

Children's Clothes & Accessories
---> slug: childrens-clothes-accessories

Children's Toys & Games
---> slug: childrens-toys-games

Sporting Goods, Fitness & Bikes
---> slug: sporting-goods-fitness-bikes

Health, Medical & Nutrition
---> slug: health-medical-nutrition

TV, Stereo & Home Electronics
---> slug: tv-stereo-home-electronics

Cell Phones & Personal Electronics
---> slug: cell-phones-personal-electronics

etc.
etc.
etc.

My navigation is using these same taxonomy terms and their slugs to get to their desired archive page of listings, which they then need to be able to search/filter further.

So for example...

1. A user opens my navigation and sees all my taxonomy terms/categories links.

2. They select: Children's Toys & Games

3. It brings them to "www.mysite.com/cat/childrens-toys-games/" where they see an archive of post listings that were posted in that specific taxonomy term/category.

4. They decide to filter by price, and see the results on the same archive page.

5. They select a post in the archive list, which brings them to the single post listing page: hidden link

Hope that all makes sense! I'm desperate for the correct solution!

I'm not sure what the correct approach is for listing taxonomy term/category archives that also have parametric search on each of them.

And if possible, where I can have the URL of each archive page be what I set them as for slugs in my taxonomy terms?

Do I need to first make a page and a view for each and every taxonomy term? Or one page and one view?

I have explored the following:

--> I tried using WordPress Archives using views, but couldn't seem to get that to work with parametric search.

--> I unsuccessfully tried to make a taxonomy archive view which filters each taxonomy term. It seemed like the wrong approach tho?

--> I read the front-end filters guide but wasn't sure what to try or if that's what I should be looking at?

--> I read passing arguments to views and that seemed to not to have the answer.

--> Currently, I'm looking at "Views Inside Views – Display Nested Multidimensional Lists", but not sure if I'm heading in the wrong direction or not?

Any insight on what I need to do to make this work would be so much appreciated!

#364596

Thank you for your kind words in regard of Toolset and I am happy that you enjoy it.

Archives, Taxonomy and user Views can't have a Parametric Search.
That's partly by design of WordPress and partly it's something we are working on to provide in future.

What you can do, is populate different form of Menus (dropdown as example), or provide links to pages, where you insert Views, which display Posts according a URL parameter Filter.

As example:

1. A Taxonomy View renders Terms where the parent is set by the Parent Taxonomy Archive View.
The Query is:

Select taxonomy terms whose parent is the current taxonomy archive.

2. In this View you create a Dropdown Menu in the Loop, which links you to a given page adding a URL parameter to it

<!-- wpv-loop-start -->
  <div class="dropdown">
    <button class="btn btn-primary dropdown-toggle" type="button" data-toggle="dropdown">Users
  <span class="caret"></span></button>
  <ul class="dropdown-menu">
    <wpv-loop>
    <li><a href="<em><u>hidden link</u></em>">Whatever you want here</a></li>
      </wpv-loop>
  </ul>
</div>
<!-- wpv-loop-end -->

3. Insert this View to the Parent Taxonomy Archive View

4. Create another View where you query posts filtered by taxonomy set in a URL parameter.
The Query is:

Select posts with taxonomy: Categories slug in one of those set by the URL parameter wpvcategory
eg. <em><u>hidden link</u></em>	

5. Create a page with slug whatever-page and insert the View in point #4

6. Now, if you click on a Dropdown menu item in the Archive you will be lead to the page, where the View will display all Posts given in that Term.

7. This last View is a Post view and actually here you can have parametric Searches, as example by Price.

DOC:
https://toolset.com/documentation/user-guides/views/
https://toolset.com/documentation/user-guides/front-page-filters/
https://toolset.com/documentation/user-guides/filtering-views-by-taxonomy/
https://toolset.com/documentation/user-guides/passing-arguments-to-views/

That's the only possible workaround the restrictions mentioned above.

Thank you

#364730

Jay

I'm so so sorry Beda! You have completely lost me. I've spent the last 5 hours attempting to do what you stated (and every other combination I could think of) as well as read those linked pages you provided many times. I'm just missing too many pieces of the puzzle.

I should have mentioned that this is my first attempt at really using views. I've only just gotten Types, CRED and Access under my belt. But I have read the entire Views manual. Yet most of it completely confused me still without directly applying it.

Could you possibly try going over this again step by step? There were lots of additional options when creating those views that I wasn't sure what to select besides what you provided in your instructions. I was confused about that dropdown as well... was that to replace my menu nav? Or part of the archive filter?

In any event, I'm going to ignore the whole navigation part of this. I'm just looking to get these taxonomy term archives set up. And have the ability to add parametric search and filtering afterwards.

One *** very *** important thing to mention. I might be calling the functionality I want by the wrong name...

What I meant by "taxonomy term archives" is a page that has an archived list of posts (that contain the post title with link, price, and picture), all within a given taxonomy category (ie: Clothing). One archive of those for EACH category term I have. Hope that makes sense!

I have deleted all my views, wordpress archives, content templates, and pages (besides all my cred form pages). So I have a clean slate so to speak.

However, my CPTs, taxonomy & terms, and custom fields are all set to go. And I have created a bunch of test listings in different categories.

For simplicities sake, lets just say I'm going to use 1 CPT, 1 Tax tied to the CPT, and 3 Tax Terms (the listing categories). So I have:

CPT:
--- Listings (slug: listing)

TAX:
--- Categories (slug: cat)

TAX TERMS:
--- Clothing (slug: clothing)
--- Jewelry (slug: jewelry)
--- Shoes (slug: shoes)

Right now, if I navigate to: "www.mysite.com/category/clothing", I see a list of links to posts that were created in the clothing category (I have my CRED forms set up so the user can only select one category from the dropdown). Same happens if I navigate to the other category slugs.

On the same page, I see a Toolset notification telling me "There is no WordPress Archive Template assigned". Am I to ignore that as I'll be making my archives with actual views rather than views > wordpress archives? Or do I need to make WordPress Archives first? Or pages?

It seems I need to create the first view for the taxonomy view before doing anything. I name it and select "Display all results", correct?

Next, I'm not sure if I am picking Post Types or Taxonomy from the "This View will display" option. I assume Taxonomy is selected there, and then my "Categories" custom taxonomy.

I'm not sure what to select on "Query Options"?

Then to the Query Filter. When I click on that, it asks me if I want to filter by: Taxonomy Search, Taxonomy Parent, or Taxonomy Term. I think it's suppose to be Taxonomy Parent. And then I choose: "Parent is the term of the current taxonomy archive page".

As for Loop Output, the whole drop down/URL filter thing has me confused. I'm not sure what the dropdown is for. Why you called it "Users". And if I'm to add list items for each of my term categories or just one list item of one category? If the latter, is it like this?

<!-- wpv-loop-start -->
<div class="dropdown">
<button class="btn btn-primary dropdown-toggle" type="button" data-toggle="dropdown">Users
<span class="caret"></span></button>
<ul class="dropdown-menu">
<wpv-loop>

  • <a href="hidden link;">Link One</a>
  • </wpv-loop>

    </div>
    <!-- wpv-loop-end -->

    I created a page for this view and inserted it into there. When I open the page, I see the drop down but it's not clear what it's for. The links go to 404 pages obviously.

    In step 3, you said: "Insert this View to the Parent Taxonomy Archive View". This is where I really got lost. I thought I was just making the Parent Taxonomy Archive View? So if not, where and how am I making that?

    As you can see, right off the bat I'm lost. I tried following the rest of your instructions but got nowhere. So would you mind giving me a step by step? I'm so sorry for my ignorance!

    And just as to not waste your time, I'll restate again... I might be calling what I need the wrong name. What I originally meant by "taxonomy term archives" is pages that each have an archive list of posts (that contain the post title with link, price, and picture), all within a given taxonomy term category (ie: Clothing). An archive like that for EACH category term.

    Thank you for any additional insight you may be able to provide!!!

    #365189

    Jay

    Sorry to pester you, but I really still can't get this to work. Any additional help would be much appreciated.

    #365203

    No Problem, let me go over it slower.

    1. Archives can not have Parametric Searches.
    There is now way to customize the WordPress Archive Query.

    The only way to achieve a similar result is as described by mea above, step by step.
    It's not replacing the Menu, but creating a DropDown of options (taxonomies terms) to click, which will lead to a "result" page where you see posts in that Term.

    2. Anyway, it seems to me you don't need a Archive.

    Please try this:

    1. Create a normal View (full custom display mode)
    2. Set your Post Type in the Content Selection
    3. Add a Parametric Search Filter in the Filter Editor.
    (Use the Button "New Filter")
    4. Choose there a Filter for your taxonomy, as example, categories.
    5. In the Loop insert some Fields too display (post title with a link as example)
    Again, use the GUI > Button "Fields and Views"
    6. Insert this View to a page.

    You will see a View Parametric Search Filter and all Posts listed below.

    This will allow you to search Posts by Category.

    I apologize my code above included the word "users", that's replaceable by any other word you want.

    It goes to a 404 because you probably either not created the results page or the URL is not 100% accurate.
    (step 5 above)

    Please let me know if above simple View already is what you need.

    No problem if not, I can login to your site and help you set uno your first Toolset Structure, I'd be happy to do that.

    Thank you

    #366441

    Jay

    Hi Beda!

    Thank you for going through the first view step by step. I'm able to filter by taxonomy term category now.

    Now, what I'm trying to accomplish next is as follows:

    1. Use direct links in my navigation menu (or just a view with direct links) which point to specific pages which have the taxonomy term filter you walked me through already applied.

    So essentially, the user is just going to navigate to a taxonomy term category which is pre-filtered. And he/she doesn't have the selectbox to switch to other term categories available. They'll use the navigation/direct links for that. I suspect I need to make an individual page for each filtered term result, but not sure if that's correct?

    2. When the user goes to a given "pre-filtered" taxonomy term category page, the URL displayed isn't the filtered search address, but redirected (or re-written) as the page slug for that term (or the page slug of the page I created).

    SO THIS:

    hidden link

    BECOMES THIS:

    hidden link

    3. On the directly linked pages the user visits which are pre-filtered by taxonomy term, they now have access to a parametric search / filters by things such as "Price, Location, etc.". Note that some pages/taxonomy term filter results will have different parametric search options than others. Hence me believing I need a separate page for each taxonomy term pre-filtered results.

    I've been able to set up #3, doing parametric search filters without issue, but not on a prefiltered category tied to a specific page.

    I see that I can insert a pre-made parametric search view on a page and it asks if I want to show the filter & results, just the filter, or just the results. I assume I'm to select only the search results on this page?

    I've been reading about passing arguments to views, views within views, and passing a URL parameter but nothing seems to make enough sense to apply it.

    Is this all possible? And if so, what is the step by step for questions: 1, 2, and 3?

    Any help is so very much appreciated!!!

    #366716

    You can use 2 different approaches.

    1. Passing the Query Argument in a URL parameter.

    With this approach you will need only one Page, and only One View inserted to that Page.

    The View will have this Query Filter:

    Select posts with taxonomy: taxonomy slug in one of those set by the URL parameter wpvcategory
    eg. <em><u>hidden link</u></em>	
    

    Then you will insert this View to any Page you want.

    The Links to the specific Terms (your menu, direct links) will need to be like this:

    your-site.com/page-with-the-view//?wpvcategory=your_term
    

    This will produce (always on the same page with the view) different results according the URL parameter you pass in the Menu Link.

    This is explained here:
    https://toolset.com/documentation/user-guides/passing-arguments-to-views/ > Controlling the filter with URL arguments
    https://toolset.com/documentation/user-guides/filtering-views-by-taxonomy/ > Value set by URL parameter

    2. For a cleaner Page URL, you need a View where you pass this value in a ShortCode attribute instead.

    But then you will need many pages (one each term/taxonomy) and each Page will hold the View, where you pass the Term in the ShortCode parameter.

    The View, will have this Query Filter instead:

     Taxonomy slug in one of those set by the View shortcode attribute wpvcategory
    eg. [wpv-view name="view-name" wpvcategory="xxxx"]	
    

    The View is then insert in the pages with each the correct ShortCode attribute:

    Example for Term "my term"
    [wpv-view name="your-view" wpvcategory="my term"]
    

    The Link from your menu (static link) will lead directly to the proper page(s)

    This is explained here:
    https://toolset.com/documentation/user-guides/passing-arguments-to-views/ > Controlling the filter with shortcode attributes
    https://toolset.com/documentation/user-guides/filtering-views-by-taxonomy/ > Value set by View shortcode attribute

    Both above solutions can hold additionally Parametric Search for any other Taxonomy or Custom field, but NEVER for the same Taxonomy you already filter by.

    Please do not hesitate to open a new thread if other issues or problems arise

    Thank you for your patience.

    #367950

    Jay

    Hi Beda!

    Thank you so much for your thorough explanation. I got everything working perfectly using the shortcode / multiple page method you outlined. 🙂

    Quick question though... The new views update that just was released has new options for querying taxonomy terms as shown here:

    hidden link

    Does this update change the approach for what I am trying to accomplish? Or do I stick with option 2 as you previously outlined?

    #367974

    Well, that is a Taxonomy View Filter, not a Post View Filter.

    I onderstond, you want to show Posts IN taxonomies, not Taxonomies the themselves.

    What you can do is, with a nested View produce the results you need.

    That means, you create a Taxonomy View with the filter you mention
    (as example, Terms with ID set by the shortcode attribute, or URL attribute)

    Then another View, queuing Posts, has a Query Filter as in:
    Select posts with taxonomy: Categories set by the parent View

    This very View is then insert in the Parent Taxonomy View.

    The Taxonomy View on it's end is insert to a Page, where you add the ShortCode parameter or pass the Term ID by URL parameter.

    It's basically the same as I already suggested previously.

    Please let me know if you have further questions regarding the issue mentioned in this Thread

    Thank you for your patience.

    #368111

    Jay

    Thanks again Beda! You are the best!

    Ok, well I can get both methods to work.

    Out of curiousity... you said, "It's basically the same as I already suggested previously."

    Would you mind explaining what the difference is between the two methods? Does either of the two methods offer performance increase or any other benefits? Or are they essentially two different ways to get the exact same results with no performance benefits?

    Again, thank you so much Beda! I love reading your support threads. You always offer the most thorough and best thought out solutions to problems we Toolset users have. You are appreciated more than you can possibly know! 🙂

    #368897

    First of all thank you very much for your kind and motivating words-

    I am happy my efforts are seen and moreover, do what they are supposed to:
    Help the users of Toolset and improve the experience of our Plugins, without just providing solutions as per "copy and paste" or "read this DOC", but with the porpoise to increase knowledge about our Toolset in a interactive way.

    Regarding your above question, it's always more resource hungry to query things more then a minimal amount of times.

    It's like if you ask in a 7/11 shop where the Drinks are, and then, once you reached the Drinks area, you ask where the Milk is.
    Way easier and faster is asking directly for Milk.

    So, given that, nesting a View is more expensive then accessing the data directly with one Query.

    That's why I suggested the direct approach with the View returning Posts by Taxonomy, instead of first querying all Taxonomies and then all posts in a second View.

    the differences are minimal (milliseconds), but now imagine this on a site with maybe 50 K posts and "some" taxonomies.

    Nesting Views can be useful if you want different Kind of Outputs depending on each other.

    As example you could want to display a List of terms and then below each Term the according Posts.
    In this case a nested View is the thing to use.

    Please let me know if you have further questions regarding the issue mentioned in this Thread

    Thank you for your patience.

    This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.