Skip Navigation

[Resolved] Record count wrong in filter

This support ticket is created 6 years, 4 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.

Our next available supporter will start replying to tickets in about 1.38 hours from now. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

This topic contains 6 replies, has 2 voices.

Last updated by Nigel 6 years, 4 months ago.

Assisted by: Nigel.

Author
Posts
#947727

I have a site with 100 records in a CPT created with toolset. These CPT are children in a partent/child relationship with another CPT, still created in toolset. I have a view listing the child cpt, and a filter to select the parent cpt. In the filter there is a count next to each parent . The sum of the values next to the parent cpt in filter returns 89 records instead of 100. Why that?

#948294

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi Gian Luca

Can you confirm how you are adding the count to the post relationship filter?

#948313

Just this:

[wpv-control-post-ancestor type="select" default_label="Select Region" format="%%NAME%% (%%COUNT%%)" ancestor_type="wine-region"]

#948324

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

OK, thanks.

Firstly, the format attribute is not documented (https://toolset.com/documentation/user-guides/views-shortcodes/#vf-521627) and so not supported, though in testing I found that it appears to work (and work correctly).

If the totals from each parent do not add up to the total number of child posts I would take that as an indication that there are child posts which are not assigned to any parent, and these are therefore missing when you add up the child posts for each parent.

#948328

That was my first assumption too. But I checked out records and, no....they have a parent assigned. All of them. Is there any way to bulk check this out?

#948330

I mean...can I create a view, for example, listing all posts that have no parent?

#948348

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

There isn't a way to add a Query Filter to only return child posts with no parent, but you can create a View to return all child posts, and then use a conditional shortcode in the output section that tests for the id of the parent post, and if there is no id then the child must be an orphan and can be displayed.

Something like this:

		<wpv-loop>
          [wpv-conditional if="( '[wpv-post-id item='@number-of-things.parent']' eq '' )"]
          <p>[wpv-post-title]</p>
          [/wpv-conditional]
		</wpv-loop>

(For the required format you can insert the wpv-post-id shortcode with the Fields and Views button where you use the post selection tab to specify that the parent post should be the source, and then copy and paste that shortcode into a wpv-conditional shortcode (adjusting quotes as required).