Skip Navigation

[Resolved] Views showing wrong content

This thread is resolved. Here is a description of the problem and solution.

Problem: I have some Views filtered by taxonomy term, set by the current page. But when the View is placed on a taxonomy archive, the term filter is not applied correctly.

Solution: It's not possible to use 'set by the current page' on a taxonomy archive, so you should switch to use shortcode attributes and pass the term in using the wpv-taxonomy-archive shortcode.

[wpv-view name='your-view-slug' terms='[wpv-taxonomy-archive info="name"]']

Relevant Documentation:
https://toolset.com/documentation/user-guides/passing-arguments-to-views/
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-taxonomy-archive

This support ticket is created 6 years, 5 months 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
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 9 replies, has 3 voices.

Last updated by rainman 6 years, 5 months ago.

Assisted by: Christian Cox.

Author
Posts
#949175
wrong-attorney.png

This is a follow up to my previous ticket https://toolset.com/forums/topic/updating-without-breaking-things/

I thought the problem was fixed, but on closer inspection I see that the content (Cases) is not being filtered properly. On this example page hidden link which is for the Attorney Doug Peters, it is listing the Cases for Bob Rubin instead (wrong attorney). On this page hidden link it is listing cases for Jason Sheffield.

These pages should list Cases that are associated with the query string for the selected Attorney (?l=441)

Please give this information to Ana Couto since she is the one who has most knowledge of the setup and was helping on it previously.

You already have a duplicator package and access credentials from the previous ticket.

#949289

I corrected a filter and added a new custom shortcode that will prevent some nested shortcode attribute issues:

// get the post slug directly from "l" URL param . This is useful when nesting shortcodes
add_shortcode('wpv-post-slug-by-l-param', 'wpv_post_slug_by_l_param_shortcode');
function wpv_post_slug_by_l_param_shortcode($atts) {
    $out = '';
  if (!empty($_GET['l']) && is_numeric($_GET['l'])) {
    $out = get_post_field('post_name', $_GET['l']);
  }
    return $out;
}

Now we can use this shortcode directly in another shortcode attribute, without having to nest two more shortcodes to access the slug of the post ID represented in the URL parameter "l":

[wpv-view name="cases by status" practicearea="[wpv-post-taxonomy-practice-area]" l="[wpv-post-slug-by-l-param]"]

I understand that all the cases should be associated with the attorney in the URL. I wasn't clear from your description - if more than one attorney is associated with a case, should their name be shown here or not? If so, please let me know and I can correct it.

#949327

The Cases are kind of like Posts that have Attorneys instead of Tags. YES, if a case is assigned to more than one attorney, it should show on any of the assigned attorneys. So for example the second case in my screenshot should show on the appropriate page for either of the two Attorneys listed. But the page title should only list the one Attorney. Each Attorney has his own set of similar pages to display his Cases.

It looks like you have it working pretty well now, except on this page hidden link there are 4 Status categories showing "No cases found". Empty entries should not be listed at all, either in the top part or in the bottom part. This example page should only show 2 categories. I'm not sure how the filters work, but I see on this page hidden link there are 4 categories listed and two are empty. Since there are more than 4 categories, some are being filtered out, but there are still two empty. The Status categories should only be listed if they contain Cases that are associated with that Attorney.

I also see some blank pages showing up, like this one hidden link
The primary Notable Cases page for each Attorney (example: hidden link) should only list Practice Areas that contain Cases associated with that Attorney.

I requested that Ana Couto work on this because she set this whole thing up a couple of years ago as a paid support job and she was the one who was just working on it two days ago. I don't really care who works on it, but we are not trying to invent something new, we're just trying to fix something that broke when we updated to the newest Toolset version. I'm a little concerned about the possibility that little changes here might break other things and she is the one who created and already understands the relationships.

#950447

Hello,

I'm Mohammed the Toolset support team leader. I see that you've requested to get support from Ana.

I'm sorry to say that this is not available because Ana doesn't belong to the support team anymore. She works with another team.

We have a system that already set to handle the clients' requests and complaints in the best way.
Christian is a top supporter and I'm sure that he can help you with this ticket. and even he got stuck, he can escalate the ticket to the next level of support and possibly to a developer if needed.

For now, Christian will help you. please collaborate with him and provide him the needed information to work on the issue and we will do our best to fix your issue.

Thanks.

#950464

Empty entries should not be listed at all, either in the top part or in the bottom part
Okay I think this is working as expected now. Please confirm. I tested on multiple practice areas and it seems to be hiding empty entries.

I also see some blank pages showing up, like this one hidden link;
I believe this is fixed now.

The primary Notable Cases page for each Attorney (example: hidden link) should only list Practice Areas that contain Cases associated with that Attorney.
Seems to be performing correctly, I tested with 3 different attorneys and found cases related to the relevant attorney for all entries here.

#950529
cases-count.png

Yes, some things are better, but the pages that were blank, like this one hidden link are behaving different than the others for some reason. Look at that page and you'll see that there are only two cases that get repeated 10 times on the page. Same for this page hidden link. The logic/filter should work the same on all the Notable Cases pages.

I'm not sure if they're actually getting all the cases should on those pages either.

I would also like to understand how the cases count works? In the administrator, go to Cases > Practice Areas and the count in right hand hand column should pull up all the cases for a particular practice area. But the numbers don't jive. In my attached screenshot, none come up for Professional Licensing Defense even though the count says 4. Same for Habeas Corpus.

#951512

Okay I fixed the issue with repeating cases. As far as the counts, the number is actually calculated from all post types that use this taxonomy term. So you'll see the total number of Cases and Attorneys with this taxonomy term. It gets a bit more confusing when hierarchical taxonomies are involved.

Please check once more and let me know what I am missing.

#951527

I think that got it. Thanks!!

I'm curious to know why cases were repeating on those 2 pages and not on other pages?

#951571

View "Practice Areas - tax", ID 103, loops over all the terms in the Practice Areas taxonomy, and shows the View "Cases status" for each term in the loop. There was a conditional in place to turn off that View of Cases if the current term in the loop does not match the current archive term, but the conditional was written in a way that does not work in a taxonomy term archive. So for each term in the taxonomy, the View of Cases was being repeated, regardless of whether or not the current term matched the current archive. I simplified the conditional so that the slug of the current archive is compared against the slug of the current term in the loop more directly.

#951574

Thanks for your help. GREAT JOB!!!