Hi Christian,
The other one is related to the Custom Taxonomy filters. I was able to successfully generate elements that are constrained by the taxonomy term, but only via the ?terms-filter=[ID] and wanted to know if there's a way to produce the same result, but without the URL parameters?
Reproduction steps: hidden link
Please let me know if you have any questions. Thank you!
1:41 - ...but when I do it in Views, it pulls back all of them.
I was able to successfully generate elements that are constrained by the taxonomy term, but only via the ?terms-filter=[ID] and wanted to know if there's a way to produce the same result, but without the URL parameters?
The taxonomy Query Filter configuration "Taxonomy is set by the page where this View is inserted" is a bit misleading in this case, because the View is inserted in an Archive. If you inserted this View in a post or page, the taxonomy terms applied to that page would be passed into the View's filter. However, in this case, there are no terms "applied" to the archive itself. You need a way to access the current archive term ID, and pass that information into the View. I would change the Query Filter to be "Terms with ID set by the shortcode attribute: terms" and then insert the View in the archive using a wpv-view shortcode. Add the terms attribute in the shortcode and provide the current archive's term ID using a nested wpv-taxonomy-archive shortcode like so:
[wpv-view name="tax-view-slug" terms="[wpv-taxonomy-archive info='id']"]
Now you've got a dynamically filtered View without the need for URL parameters. Documentation for the wpv-taxonomy-archive shortcode:
https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#wpv-taxonomy-archive
Hi Christian,
Thank you for that, I've gone ahead and tried to implement the nested shortcode suggestion, and I am seeing the following behavior:
hidden link
It seems like when I insert the wpv-taxonomy-archive shortcode by itself, the ID shows up fine. But, when I tried to insert it inside a nested view, it defaults to showing all of the terms.
Not sure offhand, did you change the View's Query Filter or is it still set to respond to a URL parameter? I can't see it in your recent video. You must change the Query Filter to be "Terms with ID set by the shortcode attribute: terms".
Hi Christian,
Yep, the query filter is set with "Terms w/ ID set by the shortcode attribute: terms"
Quick verification here: hidden link
Okay, the filter seems to be configured properly. I'm not an Oxygen expert, but I suppose it's possible their "shortcode" element does not support nested shortcodes? First, replace the wpv-taxonomy-archive shortcode with a hard-coded term ID like 64. Are the results filtered correctly? If so, then you know the issue is the nesting of shortcodes, because tested individually both components work as expected. If that is the case, maybe try with a different element, like a text element instead. I know Elementor's shortcode element does not support nested shortcodes like this.
If the hard-coded term ID does not produce the correct result, something else is going on, because the filter seems to be configured properly. Go to Toolset > Settings > Front-end Content and enable Views debug mode. Reload the archive on the front-end of the site and you'll see the debug window popup (or you may need to disable your popup blocker first). Open up all the sections of the debugger and copy the bits of information related to this specific View, paste them in your next reply, and we can review the details together.
You're right, it's possible it's a nested shortcode issue with Oxygen. It works with a hard-coded term ID, but not with the wpv taxonomy-archive shortcode. I will update as soon as I find out more. Thank you!
PS. Btw, if I included the "wpv" part of the above without the dash (as entire entire shortcode), I get this error:
hidden link
Okay standing by for your update.
Hi Christian,
Oxygen Team was able to get back to me and has said that they're able to get the shortcode to output correctly (presumably it's correct) by echoing it - here's what they're seeing output:
[wpv-view name="tax-loop-1-2-second-hero-container-in-tool-ct-of-software-cpt-relative-to-inserted-view" terms="[wpv-taxonomy-archive info='64']"]
However, it still doesn't seem to work correctly when they run it through the do_shortcode() function.
They're asking what Toolset would recommend to outputting nested shortcodes using the do_shortcode() function?
Here is the code block used in the template located here at:
hidden link
Context of code block: hidden link
Code block below:
<?php
$tax_id = get_queried_object()->term_id;
//echo "The ID is " . $tax_id . " end ID";
$shortcode_1 = '[wpv-view name="tax-loop-1-2-second-hero-container-in-tool-ct-of-software-cpt-relative-to-inserted-view"';
$shortcode_2 = 'terms="[wpv-taxonomy-archive info=';
$shortcode_3 = ']"]';
$full_shortcode = $shortcode_1 . " " . $shortcode_2 . "'" . $tax_id . "'" . $shortcode_3;
echo $full_shortcode;
// echo do_shortcode('[wpv-view name="tax-loop-1-2-second-hero-container-in-tool-ct-of-software-cpt-relative-to-inserted-view" terms="[wpv-taxonomy-archive info='id']"]');
echo do_shortcode($full_shortcode);
//[wpv-view name="tax-loop-1-2-second-hero-container-in-tool-ct-of-software-cpt-relative-to-inserted-view"
// terms="[wpv-taxonomy-archive info='id']"]
?>
I think there has been a miscommunication somewhere, because this is wrong:
[wpv-view name="tax-loop-1-2-second-hero-container-in-tool-ct-of-software-cpt-relative-to-inserted-view" terms="[wpv-taxonomy-archive info='64']"]
Instead of the value 64 in the info attribute of the wpv-taxonomy-archive shortcode, it should be id:
[wpv-view name="tax-loop-1-2-second-hero-container-in-tool-ct-of-software-cpt-relative-to-inserted-view" terms="[wpv-taxonomy-archive info='id']"]
That will make the term ID filter dynamic based on the archive where the View is displayed.
To hard-code a taxonomy term ID for testing, replace the entire wpv-taxonomy-archive shortcode like so:
[wpv-view name="tax-loop-1-2-second-hero-container-in-tool-ct-of-software-cpt-relative-to-inserted-view" terms="64"]
Hi Christian,
Commenting to continue the thread as I need to experiment with it. I haven't been able to get it work correctly and will post my discovery after I try a few different variations. Thank you for your patience!
No problem, thank you for the update.