Skip Navigation

[Resolved] Displaying parent child post types inside post archive

This support ticket is created 7 years, 12 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
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

This topic contains 6 replies, has 2 voices.

Last updated by Beda 7 years, 11 months ago.

Assisted by: Beda.

Author
Posts
#392805

I am trying to: Post Parent Child Relationship and displaying it within a post archive

I visited this URL: hidden link

I expected to see this on post archive but only displays items not found: hidden link

#392815
Screen Shot 2016-04-27 at 8.46.36 AM.png
Enernex Products - Enernex - Energy Solutions 2016-04-27 08-50-31.png
Enernex-Products---Enernex---Energy-Solutions-2016-04-27-08-50-31.jpg

I had Luo Yang helping, but his responses are slow and he does not read my comments. Hoping that you can assist as I am running out of time on this project. As per the initial info supplied I am trying to display grouped products (Parent Child Relationship) on a post archive. These product groups should only display for certain categories within in the group. I have attached a sample of excel file to one group and ideally how it should be displayed.

The attached file is for a product group called "Charge Controller" which makes use of the "Parent Child Relationship concept) Under the product group I need to display the following as per the Excel screenshot attached:

PWM controllers -eP Solar series (Sub group item Title)
Description (Description for Sub Group)
Feature (Features for Sub Group)
Table with specs (Each one of these rows inside the table is the "child" to the "Sub Group Items (PWM controllers -eP Solar series)" with the parent being "Charge Controllers".

A per below link I managed to display it correctly when clicking on the "Custom Post Archive Preview Arrow":

hidden link

I am finding it hard through to get the info to display on a post archive.

Ideally want it to display on Woocommerce post archive as this might in future become a e-commerce venture.

So in a nutshell I have done the following:

1. Created a "Parent Post Type" called: Enernex Products
2. Created a "Child Post Type" called "Charge Controllers" (more "child post types will need to be added as I have 8 product groupes)
3. Created a 2 views that displays this when added to a wordpress archive loop: hidden link - Each one of the views has a unique titlt, features and description. The "<th>" on each table is the same for all views inside this specific post type.
4. Created a post fields group containing the custom fields needed.

Thank you!

#392899

I did not find the Thread where Luo helped you with this, can you share it?

Keep in mind Table Sorting is not possible in a WordPress Archive.

As far I understand, you want to display Posts according their taxonomy (group by taxonomy)
If this is correct, we have a DOC here how to achieve this:
https://toolset.com/2015/07/how-to-group-posts-by-category/

Each Post View can of course also call Parent Fields, if you query the Child Post in those Views.

To display Child Posts of a given parent post you need a View that has a Query Filter by "Post is child of current post in the Loop" and insert this View to the "parent View" which queries the Parent Posts.

This Parent View can by itself return Posts that have the Term set by example by the Taxonomy Archive where this View is inserted.

This way you would have a List of Terms, and each Term would by itself have a list of Parent Posts with this term below it, and then for each Parent Post, the Child Posts that belong to it.

Is this not working on your end?

I will need some insight in the system in this case and will enable a private form for you to provide access.

Please make sure to add the links to where I can see the relevant Views and Contents.

Thank you

#392902

Hi, thank you for your reply. Luo has replied in the meantime, but still feel that he only gives tutorial and not real advise as to what I need to do or if there is a easier way to do this.

https://toolset.com/forums/topic/multiple-woocommerce-archive-templates-for-different-product-types/

I cant see a private private form to reply to with my login details.

#392922

I see you have a lot of questions, and to provide excellent support we need to address one issue a time, each in a single ticket.
https://toolset.com/toolset-support-policy/#support-request-guidelines

I can not read the entire Thread of Luo as this holds many different issues and I see he greatly provided answers to most of them

I can also not start debug or provide advice for things he already handles, this will cause confusion and at the end we will not solve the problem.

Let's do it like this:

1. Keep going with Luo in one topic in that thread.
2. Let's keep going here with a different Topic.

Please be concise and let me know one thing you struggle with.
Then I will provide a step by step instruction with DOC's so you can achieve it.

Please let me know with which specific step you have troubles.

To stay on topic of "Displaying parent child post types inside post archive", I suggest we proceed with tis.

You can deploy parent Posts by calling the parent Field in a View or Archive.

This is done by passing the argument "id" to your ShortCodes, while you query Child Posts.

So that means, on a View that queries your Child Post type, you call fields like this:
[wpv-post-title id="$your-parent-post-type-slug"]

This is elaborated here:
https://toolset.com/documentation/user-guides/displaying-fields-of-parent-pages/

Thank you

#393272
1.png
2.png

Thanks you, I have created a archive displaying the fields from the child post type "Charge Controller" and have also included fields into the archive loop for a description and features field located in the parent post type "Products".

When I preview the archive via the button (1.png attached) i get following (2.png - attached).

It reads the fields from the child, but not the parent. I have looked at the link you provided, not sure where I am going wrong.

See code below for the archive loop:

[wpv-layout-start]
	[wpv-items-found]
	<!-- wpv-loop-start -->
	<table width="100%">
      <h1>Charge Controllers</h1>
<table width="100%">
  <tr>
    <td>
      <h3>Description</h3>
    </td>
  </tr>
  <tr>
    <td width="50%">
      <p>[types field="description-products" id="$parent"][/types]</p>
    </td>
  </tr>
</table>
	<table width="100%">
      		<tr>
              <td valign="top">
                <h3>Features</h3>
              </td>
              <td>
              </td>
          	</tr>
          	<tr>
              <td valign="top" width="50%">
                <p>
                  <ul>
                    <li>[types field="features-products" id="$parent"][/types]</li>
                 </ul>
              </td>
          	</tr>
	</table>
	<table width="100%">
     	<tr>
			<td style="text-align: center; font-weight: bold; background-color: #6d6d6d; color: #fff;" class="title">Model</td>
			<td style="text-align: center; font-weight: bold; background-color: #6d6d6d; color: #fff;" class="tech">Input volt</td>
			<td style="text-align: center; font-weight: bold; background-color: #6d6d6d; color: #fff;" class="tech">Charging volt, Auto sensing</td>
			<td style="text-align: center; font-weight: bold; background-color: #6d6d6d; color: #fff;" class="tech">Maximum charging current</td>
			<td style="text-align: center; font-weight: bold; background-color: #6d6d6d; color: #fff;" class="tech">Maximum DC load current</td>
			<td style="text-align: center; font-weight: bold; background-color: #6d6d6d; color: #fff;" class="tech">Maximum PV input power</td>
			<td style="text-align: center; font-weight: bold; background-color: #6d6d6d; color: #fff;" class="tech">Height mm</td>
			<td style="text-align: center; font-weight: bold; background-color: #6d6d6d; color: #fff;" class="tech">Width mm</td>
			<td style="text-align: center; font-weight: bold; background-color: #6d6d6d; color: #fff;" class="tech">Depth mm</td>
		</tr>
	</table>
    <table width="100%">
		<tbody class="wpv-loop js-wpv-loop">
		<wpv-loop>
			<tr>
				[wpv-post-body view_template="Loop item in Products"]
			</tr>
		</wpv-loop>
		</tbody>
	</table>
	<!-- wpv-loop-end -->
	[/wpv-items-found]
	[wpv-no-items-found]
		<strong>[wpml-string context="wpv-views"]No items found[/wpml-string]</strong>
	[/wpv-no-items-found]
[wpv-layout-end]
#394495

I can display parent post Fields in a Archive for the Child Post Type just fine.

I used the GRID Wizard to construct my Table.

Keep in mind on Archives, Tables can not be sortable.

This below example is what you get when building it with the Wizard.

You may copy paste it and re-populate it with the correct Data.

Make Sure your Child and Parent Posts are connected and the parent Post data Exists, other wise, it will fall back to the Child Post Type Field data.

Views Loop:

[wpv-layout-start]
	[wpv-items-found]
	<!-- wpv-loop-start -->
	<table width="100%">
		<tbody class="wpv-loop js-wpv-loop">
		<wpv-loop>
			<tr>
				[wpv-post-body view_template="Loop item in IPOs"]
			</tr>
		</wpv-loop>
		</tbody>
	</table>
	<!-- wpv-loop-end -->
	[/wpv-items-found]
	[wpv-no-items-found]
		<strong>[wpml-string context="wpv-views"]No items found[/wpml-string]</strong>
	[/wpv-no-items-found]
[wpv-layout-end]

The Content Template for the Loop:
(Loop Item)

<td>[wpv-post-title]</td>
<td>[wpv-post-title id='$post']</td>
<td>[types field="additionall-notes" id="$post"][/types]</td>

My Parent post Type is "post" and the Child Post Type is "IPO"

Let me know if this works for you.

Thank you

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.