Skip Navigation

[Resolved] Views not working in certain cases

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

Problem:
Views not working in certain cases - display related parent post name in child view

Solution:
You can use the view's shortcode attribute to passed the "authorname" to child view and later use view's shortcode [wpv-attribute] to catch the passed shortcode attribute value.

You can find proposed solution, in this case, with the following reply:
https://toolset.com/forums/topic/views-not-working-in-certain-cases/#post-921312

Relevant Documentation:
=> https://toolset.com/documentation/user-guides/passing-arguments-to-views/#controlling-the-filter-with-shortcode-attributes
=> https://toolset.com/documentation/user-guides/passing-arguments-to-views/#accessing-the-arguments

This support ticket is created 6 years, 7 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
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 6 replies, has 2 voices.

Last updated by WillL606 6 years, 6 months ago.

Assisted by: Minesh.

Author
Posts
#919418

I am trying to:
I have a sidebar widget with a View (get-related-author-essay-widget) that finds the current essay's author name and presents other essays by this author. This all works fine. However, when there is more than one author to an essay, the widget is repeated not for each author as it should, but for the first author.

Link to a page where the issue can be seen:
hidden link

I expected to see:
I would like the widget View, in the case of multiple authors, to display a loop of the listed essays for each author.

Instead, I got:
The first author's essays in repeated display...

#919814

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Well - I do not know whats going on there but the string is "More essays by" is converted to "Other essays by".

And If you do not use the content template with views and just switch the content template code within the view's loop as given under with the following view:
=> hidden link

<wpv-loop>
		<p class="widget-author-name">More essays by <span class="author-link">[wpv-post-link]</span>:</p>
        [wpv-view name="display-author-related-essay-widget" wpvrelatedto="[wpv-post-id]"]
	</wpv-loop>

You will see all author names will be printed. So I think here you should have if condition if you have single author or multiple author and how you want to display the author names. I do not know how you want to display the author names.

#920568

Hi Minesh,
I have been trying to understand how to make the loop in case there are multiple authors. I would like multiple instances of the widget to appear - each one has the header OTHER ESSAY BY <author> followed by the essays of the author.

BTW- there are two views interacting here: loop-item-in-get-related-author-essay-widget which gets the author names of the current essay and then: display-author-related-essay-widget which gets the essays for the author

I tried the following, but did nothing:

 [wpv-post-body view_template="loop-item-in-get-related-author-essay-widget"]
      [wpv-item index=1]
      	[wpv-view name="display-author-related-essay-widget" wpvrelatedto="[wpv-post-id]"]
      [wpv-item index=other]
        [wpv-view name="display-author-related-essay-widget" wpvrelatedto="[wpv-post-id]"]
#920969

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

I have been trying to understand how to make the loop in case there are multiple authors. I would like multiple instances of the widget to appear - each one has the header OTHER ESSAY BY <author> followed by the essays of the author.
==> Well - the thing is here, we get authors names based on post, so when multiple authors assigned to post we will get multiple author names which belongs to same post.

am I missing anything here?

#921000

Minesh,
On this the linked page - hidden link
You see in the right sidebar that the loop is picking up the two authors Manuel Portela and Søren Pold (Maria Mecia does not have any other essays) and displaying two widgets of "OTHER ESSAYS...". The second widget, however, shows the name Manuel Portela again, even though the essay is by Søren Pold.
I think it has to do with the following loop for the "get-related-author-essay-widget" View. The shortcode needs to assign an index to each name instance?

<wpv-loop>
      [wpv-post-body view_template="loop-item-in-get-related-author-essay-widget"] // this lists author(s)
      [wpv-view name="display-author-related-essay-widget" wpvrelatedto="[wpv-post-id]"] / /this brings in essays of author(s)
</wpv-loop>
#921312

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Ok - so I've passed the "authorname" as view's shortcode attribute as you can see here:
=> hidden link

[wpv-view name="display-author-related-essay-widget" authorname='[wpv-post-link]' wpvrelatedto="[wpv-post-id]"]

And then in child view "display-author-related-essay-widget" - I catch the authorname attribute value and display it as given uder:
=> hidden link

<h6 class="author-related-essays">Other essays by <span>[wpv-attribute name="authorname"] </span></h6>

There is no need to add another child view to display just name of author.

As you can see now - its displaying author names correctly:
=> hidden link

#921371

Minesh,
That's perfect. Thanks so much.

Will