I have a view that is working fine when I add the id amanually:
[wpv-view name="get-course-price-for-cta" courseid="12335"]
I also have an attribute that is working fine to pull in an ID:
[wpv-attribute name='course-id']
However, when combined, the view breaks:
[wpv-view name="get-course-price-for-cta" courseid="[wpv-attribute name='course-id']"]
Is what I am doing not valid?
Thank you!
Hi, first I would not use "course-id" and "courseid" because it's confusing. Are these typos? Are they the same attribute? Why are they different?
Second, a lot of this depends on how you have your Views nested, and where the courseid and course-id attributes are applied. For example, let's say you have a custom Page with a View. Nested inside the Loop of that View, you have another View.
In the Page:
[wpv-view name="Your Parent View" courseid="999" locationid="123"]
In the Parent View Loop:
[wpv-view name="Your Child View" courseid="[wpv-attribute name='courseid']"]
Parent Course: [wpv-attribute name='courseid'], Parent Location: [wpv-attribute name='locationid']
Output of the Parent View: Parent Course: 999, Parent Location: 123
In the Child View Loop:
Child Course: [wpv-attribute name="courseid"], Child Location: [wpv-attribute name="locationid"]
Output in child view: Child Course: 999, Child Location:
Location is empty in the Child View, because the locationid attribute applied to the parent View shortcode is not automatically inherited by the Child View. It must be added to the Child View shortcode in order to access that value in the Child View. So I can't really tell based on your description why things aren't working as expected - I'm not able to see the hierarchy of Views to know which attributes should be inherited. To get a better understanding, I would need to see how this is all structured in wp-admin. I will activate private reply fields here so you can share login credentials, if you would like. Let me know where I can see this on the front-end of your site.
Thank you. The parent view is as follows:
[wpv-view name="content-block" blockid="34126" course-title="[wpv-post-title output='sanitize']" course-id="[wpv-post-id]"]
The output for this view uses the attribute to append a URL, e.g.,
<a href="/checkout?edd_action=add_to_cart&download_id=[wpv-attribute name='course-id']" class="button" style="width:100% !important;">
and it works great.
So now within this Parent View we have a child view. The child view simply looks at a CPT and queries on the POST ID to pull out a price.
[wpv-view name="get-course-price-for-cta" ctacourseid="XXXX"]
Since this Child View is simply doing a direct query, I am not sure how it is related to the parent view and if the attribute
[wpv-attribute name='course-id']
works in the Parent View why would it fail when inserted in the Child View?
Thank you!
The child View does not have a shortcode attribute course-id, it only has ctacourseid. The course-id value is not "inherited" automatically. You should be able to place the wpv-attribute shortcode instead of "XXXX", like this:
[wpv-view name="get-course-price-for-cta" ctacourseid="[wpv-attribute name='course-id']"]
The Child View's post ID Query Filter must be set up to respond to a shortcode attribute ctacourseid. Inside the child View, you can access the course ID like this:
Value of original course-id value: [wpv-attribute name='ctacourseid']
Thanks, yes, that is exactly what I have:
[wpv-view name="get-course-price-for-cta" ctacourseid="[wpv-attribute name='course-id']"]
The resulting output is:
<! --- View not found -->
"]
However, if I manually enter in a ctacourseid the view works perfectly.
Try deleting the hyphen from the course-id attributes and attribute shortcodes. Only lowercase letters and numbers should be used in these attributes, as I was just reminded while trying to test a Query Filter (see the screenshot).
[wpv-view name="content-block" blockid="34126" course-title="[wpv-post-title output='sanitize']" courseid="[wpv-post-id]"]
[wpv-view name="get-course-price-for-cta" ctacourseid="[wpv-attribute name='courseid']"]
If this isn't working, I'll need some more context. If you provide login credentials, I can take a look in your wp-admin panel. Private reply fields are active here.