Hi, I am using a flat taxonomy structure but need to exclude some taxonomy showing up in the Area column in this table view loop:
hidden link
Here is the code:
<wpv-loop>
<tr>
<td>[wpv-post-link]</td>
<td>[wpv-post-taxonomy type="faculty-fields"]</td>
<td>[types field='research-statement-or-question'][/types]</td>
</tr>
</wpv-loop>
However, I want to display only specific ones and eliminate displaying other ones like "Ladder Faculty". I tried using the taxonomy filter but this is not working. Please see my screenshot. Please advise.
Hello and thank you for contacting Toolset support.
To better assist you with this request, I need to ask the following question:
Do you want to hide only certain taxonomy terms(such as "Ladder Faculty"), or do you want to also hide their posts? If, we take the first row in this screenshot hidden link Do you want to hide only the link to "Ladder Faculty" or the whole row?
If you want to hide only the specific taxonomy terms, the best solution would be to create a custom shortcode to display the taxonomy terms instead of relying on the wpv-post-taxonomy shortcode.
Let me know further about your use case, and I'll do my best to help.
Thanks, I'm not able to view your screenshot. I need to hide just specific terms like "Ladder Faculty" not the whole row since each faculty has more than one taxonomy attached to them. Please note that the table contents in this View are formed by a loop: hidden link
and I'm not sure how to create a shortcode to insert and loop through the table cells. Please advise.
My apologies for the late reply, but I do not work on Wednesdays and Thursdays as you may check on my profile page https://toolset.com/forums/users/jamal-b/
To exclude only one term from the output of the wpv-post-taxonomy shortcode, you will require custom code. The following code should work for you, add it to Toolset->Settings->Custom Code and make sure it is active.
function exclude_taxonomy_term($terms, $object_ids, $taxonomies, $args) {
global $WP_Views;
$taxonomy = "faculty";
$term_slug = "ladder-faculty";
$view_id = 1723;
if ( $WP_Views->current_view == $view_id ) {
foreach( $terms as $i => $term ) {
if ( $term->slug == $term_slug && $term->taxonomy == $taxonomy ) {
unset( $terms[$i] );
}
}
}
return $terms;
}
I run a small test on my local test site and it seems to work. Please note that this custom code will only work for custom taxonomies. It won't work for default taxonomies(categories and tags).
If this does not work for you, please allow me temporary access to your website to check it further. Your next reply will be private to let you share credentials safely. ** Make a database backup before sharing credentials. **
I hope this helps. Let me know if you have any questions.
Thank you for that. However, it doesn't seem to be working and I'm still seeing all the terms on the front-end. Please see attached screenshot of the settings. The code is also 'active'.
hidden link
Since this site is on a university network, it will be challenging for me to get you access so hopefully we can figure out what is going on this way. Thanks.
Can you reload the custom code settings page, sometimes the snippet appears active, but it is not really active. It is a minor issue that we'll fix in an upcoming release.
If that's not the case, I am afraid, I'll need to debug it further. If you can't provide access to your site, maybe you can provide a copy using Duplicator or All In One Migration? Or I can send you some instructions to migrate a copy of your website into our platform? Once we help you achieve your request, we'll delete the copy from our side. I am setting your next reply as private to let your share the copy's download link. Please create an administrator user for us before copying the site and share its credentials with us. Then remove it or change its password.
Let me know if you would prefer to perform the migration, so I'll create the target server.
Hi, I noticed that I don't see any reference to the taxonomy type="faculty-fields" in your php code, could that be the issue?
Basically you should adapt lines 4-5-6 to your existing data:
$taxonomy = "faculty";
$term_slug = "ladder-faculty";
$view_id = 1723;
Apparently, line 4 should be "faculty-fields":
$taxonomy = "faculty-fields";
I'll activate the private reply in case you still need assistance.
It doesn't work with faculty-fields either. Is there a setting I'm missing here? What else could be the issue?
I can't really tell anymore. I'll need to debug it in order to know what's going on. From my side, the code works as it should.
So, we are getting to the stage where you need to provide a copy of your website to push this further. Your next reply will be private to let you share credentials and download links safely.
I have finished my shift for today. I can work on it tomorrow if you provide the copy. Please let me know what view and where it is displayed.
Hi, I am able to give you access to our site, can you please provide the private reply option so I can send you the credentials? Thanks.
Sure. Your next reply will be private to let you share credentials safely. ** Make a database backup before sharing credentials. **
Hello and my apologies for the late reply, but I do not work on Wednesdays and Thursdays as you may check on my profile page https://toolset.com/forums/users/jamal-b/
I forget a line of code that should be added to the custom code:
add_filter('wp_get_object_terms', 'exclude_taxonomy_term', 10, 4);
Unfortunately, that did not seem to be the only issue. The code does not exclude the term from the results. I need to debug this in my local development environment. I will need your approval to take a copy of your website and debug it locally. Let me know if that's fine with you.
Hello, can I please get an update on this? Thanks.